aboutsummaryrefslogtreecommitdiff
path: root/src/yuzu/configuration
diff options
context:
space:
mode:
authorMorph <39850852+Morph1984@users.noreply.github.com>2021-05-25 19:32:56 -0400
committerGitHub <noreply@github.com>2021-05-25 19:32:56 -0400
commit065867e2c24e9856c360fc2d6b9a86c92aedc43e (patch)
tree7964e85ef4f01a3c2b8f44e850f37b384405b930 /src/yuzu/configuration
parent08a5cf0b5bd43f63122cb722f5ecce89ab01a160 (diff)
common: fs: Rework the Common Filesystem interface to make use of std::filesystem (#6270)
* common: fs: fs_types: Create filesystem types Contains various filesystem types used by the Common::FS library * common: fs: fs_util: Add std::string to std::u8string conversion utility * common: fs: path_util: Add utlity functions for paths Contains various utility functions for getting or manipulating filesystem paths used by the Common::FS library * common: fs: file: Rewrite the IOFile implementation * common: fs: Reimplement Common::FS library using std::filesystem * common: fs: fs_paths: Add fs_paths to replace common_paths * common: fs: path_util: Add the rest of the path functions * common: Remove the previous Common::FS implementation * general: Remove unused fs includes * string_util: Remove unused function and include * nvidia_flags: Migrate to the new Common::FS library * settings: Migrate to the new Common::FS library * logging: backend: Migrate to the new Common::FS library * core: Migrate to the new Common::FS library * perf_stats: Migrate to the new Common::FS library * reporter: Migrate to the new Common::FS library * telemetry_session: Migrate to the new Common::FS library * key_manager: Migrate to the new Common::FS library * bis_factory: Migrate to the new Common::FS library * registered_cache: Migrate to the new Common::FS library * xts_archive: Migrate to the new Common::FS library * service: acc: Migrate to the new Common::FS library * applets/profile: Migrate to the new Common::FS library * applets/web: Migrate to the new Common::FS library * service: filesystem: Migrate to the new Common::FS library * loader: Migrate to the new Common::FS library * gl_shader_disk_cache: Migrate to the new Common::FS library * nsight_aftermath_tracker: Migrate to the new Common::FS library * vulkan_library: Migrate to the new Common::FS library * configure_debug: Migrate to the new Common::FS library * game_list_worker: Migrate to the new Common::FS library * config: Migrate to the new Common::FS library * configure_filesystem: Migrate to the new Common::FS library * configure_per_game_addons: Migrate to the new Common::FS library * configure_profile_manager: Migrate to the new Common::FS library * configure_ui: Migrate to the new Common::FS library * input_profiles: Migrate to the new Common::FS library * yuzu_cmd: config: Migrate to the new Common::FS library * yuzu_cmd: Migrate to the new Common::FS library * vfs_real: Migrate to the new Common::FS library * vfs: Migrate to the new Common::FS library * vfs_libzip: Migrate to the new Common::FS library * service: bcat: Migrate to the new Common::FS library * yuzu: main: Migrate to the new Common::FS library * vfs_real: Delete the contents of an existing file in CreateFile Current usages of CreateFile expect to delete the contents of an existing file, retain this behavior for now. * input_profiles: Don't iterate the input profile dir if it does not exist Silences an error produced in the log if the directory does not exist. * game_list_worker: Skip parsing file if the returned VfsFile is nullptr Prevents crashes in GetLoader when the virtual file is nullptr * common: fs: Validate paths for path length * service: filesystem: Open the mod load directory as read only
Diffstat (limited to 'src/yuzu/configuration')
-rw-r--r--src/yuzu/configuration/config.cpp98
-rw-r--r--src/yuzu/configuration/configure_debug.cpp4
-rw-r--r--src/yuzu/configuration/configure_filesystem.cpp39
-rw-r--r--src/yuzu/configuration/configure_per_game.cpp2
-rw-r--r--src/yuzu/configuration/configure_per_game_addons.cpp8
-rw-r--r--src/yuzu/configuration/configure_profile_manager.cpp13
-rw-r--r--src/yuzu/configuration/configure_system.cpp1
-rw-r--r--src/yuzu/configuration/configure_ui.cpp23
-rw-r--r--src/yuzu/configuration/input_profiles.cpp58
9 files changed, 124 insertions, 122 deletions
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index 21d1dc1749..eb58bfa5b9 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -5,8 +5,8 @@
#include <array>
#include <QKeySequence>
#include <QSettings>
-#include "common/common_paths.h"
-#include "common/file_util.h"
+#include "common/fs/fs.h"
+#include "common/fs/path_util.h"
#include "core/core.h"
#include "core/hle/service/acc/profile_manager.h"
#include "core/hle/service/hid/controllers/npad.h"
@@ -243,27 +243,27 @@ const std::array<UISettings::Shortcut, 17> Config::default_hotkeys{{
// clang-format on
void Config::Initialize(const std::string& config_name) {
+ const auto fs_config_loc = FS::GetYuzuPath(FS::YuzuPath::ConfigDir);
+ const auto config_file = fmt::format("{}.ini", config_name);
+
switch (type) {
case ConfigType::GlobalConfig:
- qt_config_loc = fmt::format("{}" DIR_SEP "{}.ini", FS::GetUserPath(FS::UserPath::ConfigDir),
- config_name);
- FS::CreateFullPath(qt_config_loc);
+ qt_config_loc = FS::PathToUTF8String(fs_config_loc / config_file);
+ void(FS::CreateParentDir(qt_config_loc));
qt_config = std::make_unique<QSettings>(QString::fromStdString(qt_config_loc),
QSettings::IniFormat);
Reload();
break;
case ConfigType::PerGameConfig:
- qt_config_loc = fmt::format("{}custom" DIR_SEP "{}.ini",
- FS::GetUserPath(FS::UserPath::ConfigDir), config_name);
- FS::CreateFullPath(qt_config_loc);
+ qt_config_loc = FS::PathToUTF8String(fs_config_loc / "custom" / config_file);
+ void(FS::CreateParentDir(qt_config_loc));
qt_config = std::make_unique<QSettings>(QString::fromStdString(qt_config_loc),
QSettings::IniFormat);
Reload();
break;
case ConfigType::InputProfile:
- qt_config_loc = fmt::format("{}input" DIR_SEP "{}.ini",
- FS::GetUserPath(FS::UserPath::ConfigDir), config_name);
- FS::CreateFullPath(qt_config_loc);
+ qt_config_loc = FS::PathToUTF8String(fs_config_loc / "input" / config_file);
+ void(FS::CreateParentDir(qt_config_loc));
qt_config = std::make_unique<QSettings>(QString::fromStdString(qt_config_loc),
QSettings::IniFormat);
break;
@@ -598,30 +598,34 @@ void Config::ReadDataStorageValues() {
qt_config->beginGroup(QStringLiteral("Data Storage"));
Settings::values.use_virtual_sd = ReadSetting(QStringLiteral("use_virtual_sd"), true).toBool();
- FS::GetUserPath(FS::UserPath::NANDDir,
- qt_config
- ->value(QStringLiteral("nand_directory"),
- QString::fromStdString(FS::GetUserPath(FS::UserPath::NANDDir)))
- .toString()
- .toStdString());
- FS::GetUserPath(FS::UserPath::SDMCDir,
- qt_config
- ->value(QStringLiteral("sdmc_directory"),
- QString::fromStdString(FS::GetUserPath(FS::UserPath::SDMCDir)))
- .toString()
- .toStdString());
- FS::GetUserPath(FS::UserPath::LoadDir,
- qt_config
- ->value(QStringLiteral("load_directory"),
- QString::fromStdString(FS::GetUserPath(FS::UserPath::LoadDir)))
- .toString()
- .toStdString());
- FS::GetUserPath(FS::UserPath::DumpDir,
- qt_config
- ->value(QStringLiteral("dump_directory"),
- QString::fromStdString(FS::GetUserPath(FS::UserPath::DumpDir)))
- .toString()
- .toStdString());
+ FS::SetYuzuPath(
+ FS::YuzuPath::NANDDir,
+ qt_config
+ ->value(QStringLiteral("nand_directory"),
+ QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::NANDDir)))
+ .toString()
+ .toStdString());
+ FS::SetYuzuPath(
+ FS::YuzuPath::SDMCDir,
+ qt_config
+ ->value(QStringLiteral("sdmc_directory"),
+ QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::SDMCDir)))
+ .toString()
+ .toStdString());
+ FS::SetYuzuPath(
+ FS::YuzuPath::LoadDir,
+ qt_config
+ ->value(QStringLiteral("load_directory"),
+ QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::LoadDir)))
+ .toString()
+ .toStdString());
+ FS::SetYuzuPath(
+ FS::YuzuPath::DumpDir,
+ qt_config
+ ->value(QStringLiteral("dump_directory"),
+ QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir)))
+ .toString()
+ .toStdString());
Settings::values.gamecard_inserted =
ReadSetting(QStringLiteral("gamecard_inserted"), false).toBool();
Settings::values.gamecard_current_game =
@@ -817,11 +821,11 @@ void Config::ReadScreenshotValues() {
UISettings::values.enable_screenshot_save_as =
ReadSetting(QStringLiteral("enable_screenshot_save_as"), true).toBool();
- FS::GetUserPath(
- FS::UserPath::ScreenshotsDir,
+ FS::SetYuzuPath(
+ FS::YuzuPath::ScreenshotsDir,
qt_config
->value(QStringLiteral("screenshot_path"),
- QString::fromStdString(FS::GetUserPath(FS::UserPath::ScreenshotsDir)))
+ QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::ScreenshotsDir)))
.toString()
.toStdString());
@@ -1220,17 +1224,17 @@ void Config::SaveDataStorageValues() {
WriteSetting(QStringLiteral("use_virtual_sd"), Settings::values.use_virtual_sd, true);
WriteSetting(QStringLiteral("nand_directory"),
- QString::fromStdString(FS::GetUserPath(FS::UserPath::NANDDir)),
- QString::fromStdString(FS::GetUserPath(FS::UserPath::NANDDir)));
+ QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::NANDDir)),
+ QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::NANDDir)));
WriteSetting(QStringLiteral("sdmc_directory"),
- QString::fromStdString(FS::GetUserPath(FS::UserPath::SDMCDir)),
- QString::fromStdString(FS::GetUserPath(FS::UserPath::SDMCDir)));
+ QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::SDMCDir)),
+ QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::SDMCDir)));
WriteSetting(QStringLiteral("load_directory"),
- QString::fromStdString(FS::GetUserPath(FS::UserPath::LoadDir)),
- QString::fromStdString(FS::GetUserPath(FS::UserPath::LoadDir)));
+ QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::LoadDir)),
+ QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::LoadDir)));
WriteSetting(QStringLiteral("dump_directory"),
- QString::fromStdString(FS::GetUserPath(FS::UserPath::DumpDir)),
- QString::fromStdString(FS::GetUserPath(FS::UserPath::DumpDir)));
+ QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir)),
+ QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::DumpDir)));
WriteSetting(QStringLiteral("gamecard_inserted"), Settings::values.gamecard_inserted, false);
WriteSetting(QStringLiteral("gamecard_current_game"), Settings::values.gamecard_current_game,
false);
@@ -1397,7 +1401,7 @@ void Config::SaveScreenshotValues() {
WriteSetting(QStringLiteral("enable_screenshot_save_as"),
UISettings::values.enable_screenshot_save_as);
WriteSetting(QStringLiteral("screenshot_path"),
- QString::fromStdString(FS::GetUserPath(FS::UserPath::ScreenshotsDir)));
+ QString::fromStdString(FS::GetYuzuPathString(FS::YuzuPath::ScreenshotsDir)));
qt_config->endGroup();
}
diff --git a/src/yuzu/configuration/configure_debug.cpp b/src/yuzu/configuration/configure_debug.cpp
index 6730eb3563..b207e07cb0 100644
--- a/src/yuzu/configuration/configure_debug.cpp
+++ b/src/yuzu/configuration/configure_debug.cpp
@@ -4,7 +4,7 @@
#include <QDesktopServices>
#include <QUrl>
-#include "common/file_util.h"
+#include "common/fs/path_util.h"
#include "common/logging/backend.h"
#include "common/logging/filter.h"
#include "common/settings.h"
@@ -20,7 +20,7 @@ ConfigureDebug::ConfigureDebug(QWidget* parent) : QWidget(parent), ui(new Ui::Co
connect(ui->open_log_button, &QPushButton::clicked, []() {
const auto path =
- QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::LogDir));
+ QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::LogDir));
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
});
}
diff --git a/src/yuzu/configuration/configure_filesystem.cpp b/src/yuzu/configuration/configure_filesystem.cpp
index 006eda4b00..d223c40ea2 100644
--- a/src/yuzu/configuration/configure_filesystem.cpp
+++ b/src/yuzu/configuration/configure_filesystem.cpp
@@ -4,8 +4,8 @@
#include <QFileDialog>
#include <QMessageBox>
-#include "common/common_paths.h"
-#include "common/file_util.h"
+#include "common/fs/fs.h"
+#include "common/fs/path_util.h"
#include "common/settings.h"
#include "ui_configure_filesystem.h"
#include "yuzu/configuration/configure_filesystem.h"
@@ -40,14 +40,14 @@ ConfigureFilesystem::~ConfigureFilesystem() = default;
void ConfigureFilesystem::setConfiguration() {
ui->nand_directory_edit->setText(
- QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::NANDDir)));
+ QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::NANDDir)));
ui->sdmc_directory_edit->setText(
- QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir)));
+ QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::SDMCDir)));
ui->gamecard_path_edit->setText(QString::fromStdString(Settings::values.gamecard_path));
ui->dump_path_edit->setText(
- QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::DumpDir)));
+ QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::DumpDir)));
ui->load_path_edit->setText(
- QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::LoadDir)));
+ QString::fromStdString(Common::FS::GetYuzuPathString(Common::FS::YuzuPath::LoadDir)));
ui->gamecard_inserted->setChecked(Settings::values.gamecard_inserted);
ui->gamecard_current_game->setChecked(Settings::values.gamecard_current_game);
@@ -60,13 +60,13 @@ void ConfigureFilesystem::setConfiguration() {
}
void ConfigureFilesystem::applyConfiguration() {
- Common::FS::GetUserPath(Common::FS::UserPath::NANDDir,
+ Common::FS::SetYuzuPath(Common::FS::YuzuPath::NANDDir,
ui->nand_directory_edit->text().toStdString());
- Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir,
+ Common::FS::SetYuzuPath(Common::FS::YuzuPath::SDMCDir,
ui->sdmc_directory_edit->text().toStdString());
- Common::FS::GetUserPath(Common::FS::UserPath::DumpDir,
+ Common::FS::SetYuzuPath(Common::FS::YuzuPath::DumpDir,
ui->dump_path_edit->text().toStdString());
- Common::FS::GetUserPath(Common::FS::UserPath::LoadDir,
+ Common::FS::SetYuzuPath(Common::FS::YuzuPath::LoadDir,
ui->load_path_edit->text().toStdString());
Settings::values.gamecard_inserted = ui->gamecard_inserted->isChecked();
@@ -104,25 +104,26 @@ void ConfigureFilesystem::SetDirectory(DirectoryTarget target, QLineEdit* edit)
QStringLiteral("NX Gamecard;*.xci"));
} else {
str = QFileDialog::getExistingDirectory(this, caption, edit->text());
- if (!str.isNull() && str.back() != QDir::separator()) {
- str.append(QDir::separator());
- }
}
- if (str.isEmpty())
+ if (str.isNull() || str.isEmpty()) {
return;
+ }
+
+ if (str.back() != QChar::fromLatin1('/')) {
+ str.append(QChar::fromLatin1('/'));
+ }
edit->setText(str);
}
void ConfigureFilesystem::ResetMetadata() {
- if (!Common::FS::Exists(Common::FS::GetUserPath(Common::FS::UserPath::CacheDir) + DIR_SEP +
- "game_list")) {
+ if (!Common::FS::Exists(Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) /
+ "game_list/")) {
QMessageBox::information(this, tr("Reset Metadata Cache"),
tr("The metadata cache is already empty."));
- } else if (Common::FS::DeleteDirRecursively(
- Common::FS::GetUserPath(Common::FS::UserPath::CacheDir) + DIR_SEP +
- "game_list")) {
+ } else if (Common::FS::RemoveDirRecursively(
+ Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) / "game_list")) {
QMessageBox::information(this, tr("Reset Metadata Cache"),
tr("The operation completed successfully."));
UISettings::values.is_game_list_reload_pending.exchange(true);
diff --git a/src/yuzu/configuration/configure_per_game.cpp b/src/yuzu/configuration/configure_per_game.cpp
index f550567e25..3e13bd4387 100644
--- a/src/yuzu/configuration/configure_per_game.cpp
+++ b/src/yuzu/configuration/configure_per_game.cpp
@@ -14,8 +14,6 @@
#include <QTimer>
#include <QTreeView>
-#include "common/common_paths.h"
-#include "common/file_util.h"
#include "core/core.h"
#include "core/file_sys/control_metadata.h"
#include "core/file_sys/patch_manager.h"
diff --git a/src/yuzu/configuration/configure_per_game_addons.cpp b/src/yuzu/configuration/configure_per_game_addons.cpp
index cdeeec01c0..9b709d4051 100644
--- a/src/yuzu/configuration/configure_per_game_addons.cpp
+++ b/src/yuzu/configuration/configure_per_game_addons.cpp
@@ -13,8 +13,8 @@
#include <QTimer>
#include <QTreeView>
-#include "common/common_paths.h"
-#include "common/file_util.h"
+#include "common/fs/fs.h"
+#include "common/fs/path_util.h"
#include "core/core.h"
#include "core/file_sys/patch_manager.h"
#include "core/file_sys/xts_archive.h"
@@ -79,8 +79,8 @@ void ConfigurePerGameAddons::ApplyConfiguration() {
std::sort(disabled_addons.begin(), disabled_addons.end());
std::sort(current.begin(), current.end());
if (disabled_addons != current) {
- Common::FS::Delete(Common::FS::GetUserPath(Common::FS::UserPath::CacheDir) + DIR_SEP +
- "game_list" + DIR_SEP + fmt::format("{:016X}.pv.txt", title_id));
+ void(Common::FS::RemoveFile(Common::FS::GetYuzuPath(Common::FS::YuzuPath::CacheDir) /
+ "game_list" / fmt::format("{:016X}.pv.txt", title_id)));
}
Settings::values.disabled_addons[title_id] = disabled_addons;
diff --git a/src/yuzu/configuration/configure_profile_manager.cpp b/src/yuzu/configuration/configure_profile_manager.cpp
index d61b5e29b1..f5881e58dc 100644
--- a/src/yuzu/configuration/configure_profile_manager.cpp
+++ b/src/yuzu/configuration/configure_profile_manager.cpp
@@ -12,7 +12,7 @@
#include <QTreeView>
#include <QVBoxLayout>
#include "common/assert.h"
-#include "common/file_util.h"
+#include "common/fs/path_util.h"
#include "common/settings.h"
#include "common/string_util.h"
#include "core/core.h"
@@ -34,9 +34,10 @@ constexpr std::array<u8, 107> backup_jpeg{
};
QString GetImagePath(Common::UUID uuid) {
- const auto path = Common::FS::GetUserPath(Common::FS::UserPath::NANDDir) +
- "/system/save/8000000000000010/su/avators/" + uuid.FormatSwitch() + ".jpg";
- return QString::fromStdString(path);
+ const auto path =
+ Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) /
+ fmt::format("system/save/8000000000000010/su/avators/{}.jpg", uuid.FormatSwitch());
+ return QString::fromStdString(Common::FS::PathToUTF8String(path));
}
QString GetAccountUsername(const Service::Account::ProfileManager& manager, Common::UUID uuid) {
@@ -281,8 +282,8 @@ void ConfigureProfileManager::SetUserImage() {
return;
}
- const auto raw_path = QString::fromStdString(
- Common::FS::GetUserPath(Common::FS::UserPath::NANDDir) + "/system/save/8000000000000010");
+ const auto raw_path = QString::fromStdString(Common::FS::PathToUTF8String(
+ Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir) / "system/save/8000000000000010"));
const QFileInfo raw_info{raw_path};
if (raw_info.exists() && !raw_info.isDir() && !QFile::remove(raw_path)) {
QMessageBox::warning(this, tr("Error deleting file"),
diff --git a/src/yuzu/configuration/configure_system.cpp b/src/yuzu/configuration/configure_system.cpp
index 85418f9699..99a5df241c 100644
--- a/src/yuzu/configuration/configure_system.cpp
+++ b/src/yuzu/configuration/configure_system.cpp
@@ -10,7 +10,6 @@
#include <QGraphicsItem>
#include <QMessageBox>
#include "common/assert.h"
-#include "common/file_util.h"
#include "common/settings.h"
#include "core/core.h"
#include "core/hle/service/time/time.h"
diff --git a/src/yuzu/configuration/configure_ui.cpp b/src/yuzu/configuration/configure_ui.cpp
index 0cdaea8a4a..0a28c87c06 100644
--- a/src/yuzu/configuration/configure_ui.cpp
+++ b/src/yuzu/configuration/configure_ui.cpp
@@ -8,7 +8,7 @@
#include <QDirIterator>
#include "common/common_types.h"
-#include "common/file_util.h"
+#include "common/fs/path_util.h"
#include "common/settings.h"
#include "core/core.h"
#include "ui_configure_ui.h"
@@ -62,13 +62,16 @@ ConfigureUi::ConfigureUi(QWidget* parent) : QWidget(parent), ui(new Ui::Configur
// Set screenshot path to user specification.
connect(ui->screenshot_path_button, &QToolButton::pressed, this, [this] {
- const QString& filename =
+ auto dir =
QFileDialog::getExistingDirectory(this, tr("Select Screenshots Path..."),
- QString::fromStdString(Common::FS::GetUserPath(
- Common::FS::UserPath::ScreenshotsDir))) +
- QDir::separator();
- if (!filename.isEmpty()) {
- ui->screenshot_path_edit->setText(filename);
+ QString::fromStdString(Common::FS::GetYuzuPathString(
+ Common::FS::YuzuPath::ScreenshotsDir)));
+ if (!dir.isEmpty()) {
+ if (dir.back() != QChar::fromLatin1('/')) {
+ dir.append(QChar::fromLatin1('/'));
+ }
+
+ ui->screenshot_path_edit->setText(dir);
}
});
}
@@ -84,7 +87,7 @@ void ConfigureUi::ApplyConfiguration() {
UISettings::values.row_2_text_id = ui->row_2_text_combobox->currentData().toUInt();
UISettings::values.enable_screenshot_save_as = ui->enable_screenshot_save_as->isChecked();
- Common::FS::GetUserPath(Common::FS::UserPath::ScreenshotsDir,
+ Common::FS::SetYuzuPath(Common::FS::YuzuPath::ScreenshotsDir,
ui->screenshot_path_edit->text().toStdString());
Core::System::GetInstance().ApplySettings();
}
@@ -102,8 +105,8 @@ void ConfigureUi::SetConfiguration() {
ui->icon_size_combobox->findData(UISettings::values.icon_size));
ui->enable_screenshot_save_as->setChecked(UISettings::values.enable_screenshot_save_as);
- ui->screenshot_path_edit->setText(
- QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::ScreenshotsDir)));
+ ui->screenshot_path_edit->setText(QString::fromStdString(
+ Common::FS::GetYuzuPathString(Common::FS::YuzuPath::ScreenshotsDir)));
}
void ConfigureUi::changeEvent(QEvent* event) {
diff --git a/src/yuzu/configuration/input_profiles.cpp b/src/yuzu/configuration/input_profiles.cpp
index e87aededb3..333eeb84ec 100644
--- a/src/yuzu/configuration/input_profiles.cpp
+++ b/src/yuzu/configuration/input_profiles.cpp
@@ -4,8 +4,8 @@
#include <fmt/format.h>
-#include "common/common_paths.h"
-#include "common/file_util.h"
+#include "common/fs/fs.h"
+#include "common/fs/path_util.h"
#include "yuzu/configuration/config.h"
#include "yuzu/configuration/input_profiles.h"
@@ -14,47 +14,43 @@ namespace FS = Common::FS;
namespace {
bool ProfileExistsInFilesystem(std::string_view profile_name) {
- return FS::Exists(fmt::format("{}input" DIR_SEP "{}.ini",
- FS::GetUserPath(FS::UserPath::ConfigDir), profile_name));
+ return FS::Exists(FS::GetYuzuPath(FS::YuzuPath::ConfigDir) / "input" /
+ fmt::format("{}.ini", profile_name));
}
-bool IsINI(std::string_view filename) {
- const std::size_t index = filename.rfind('.');
-
- if (index == std::string::npos) {
- return false;
- }
-
- return filename.substr(index) == ".ini";
+bool IsINI(const std::filesystem::path& filename) {
+ return filename.extension() == ".ini";
}
-std::string GetNameWithoutExtension(const std::string& filename) {
- const std::size_t index = filename.rfind('.');
-
- if (index == std::string::npos) {
- return filename;
- }
-
- return filename.substr(0, index);
+std::filesystem::path GetNameWithoutExtension(std::filesystem::path filename) {
+ return filename.replace_extension();
}
} // namespace
InputProfiles::InputProfiles() {
- const std::string input_profile_loc =
- fmt::format("{}input", FS::GetUserPath(FS::UserPath::ConfigDir));
+ const auto input_profile_loc = FS::GetYuzuPath(FS::YuzuPath::ConfigDir) / "input";
+
+ if (!FS::IsDir(input_profile_loc)) {
+ return;
+ }
- FS::ForeachDirectoryEntry(
- nullptr, input_profile_loc,
- [this](u64* entries_out, const std::string& directory, const std::string& filename) {
- if (IsINI(filename) && IsProfileNameValid(GetNameWithoutExtension(filename))) {
+ FS::IterateDirEntries(
+ input_profile_loc,
+ [this](const std::filesystem::path& full_path) {
+ const auto filename = full_path.filename();
+ const auto name_without_ext =
+ Common::FS::PathToUTF8String(GetNameWithoutExtension(filename));
+
+ if (IsINI(filename) && IsProfileNameValid(name_without_ext)) {
map_profiles.insert_or_assign(
- GetNameWithoutExtension(filename),
- std::make_unique<Config>(GetNameWithoutExtension(filename),
- Config::ConfigType::InputProfile));
+ name_without_ext,
+ std::make_unique<Config>(name_without_ext, Config::ConfigType::InputProfile));
}
+
return true;
- });
+ },
+ FS::DirEntryFilter::File);
}
InputProfiles::~InputProfiles() = default;
@@ -96,7 +92,7 @@ bool InputProfiles::DeleteProfile(const std::string& profile_name) {
}
if (!ProfileExistsInFilesystem(profile_name) ||
- FS::Delete(map_profiles[profile_name]->GetConfigFilePath())) {
+ FS::RemoveFile(map_profiles[profile_name]->GetConfigFilePath())) {
map_profiles.erase(profile_name);
}