From 281f2926bbc6ecc4db6ff517b718a01c3a0d0bb5 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 30 Oct 2022 21:03:49 +0200 Subject: [PATCH] common/fileutil: Convert namespace to Common::FS Migrates a remaining common file over to the Common namespace, making it consistent with the rest of common files. This also allows for high-traffic FS related code to alias the filesystem function namespace as namespace FS = Common::FS; for more concise typing. --- src/android/app/src/main/jni/config.cpp | 6 +- src/android/app/src/main/jni/game_info.cpp | 2 +- src/android/app/src/main/jni/id_cache.cpp | 4 +- src/android/app/src/main/jni/native.cpp | 14 ++-- src/audio_core/hle/ffmpeg_dl.cpp | 4 +- src/citra/citra.cpp | 4 +- src/citra/config.cpp | 10 +-- src/citra_qt/configuration/config.cpp | 12 ++-- .../configuration/configure_debug.cpp | 2 +- .../configuration/configure_general.cpp | 6 +- .../configuration/configure_storage.cpp | 24 +++---- src/citra_qt/game_list.cpp | 30 ++++---- src/citra_qt/game_list_worker.cpp | 14 ++-- src/citra_qt/main.cpp | 34 +++++----- src/common/file_util.cpp | 40 +++++------ src/common/file_util.h | 4 +- src/common/logging/backend.cpp | 10 +-- src/common/logging/backend.h | 2 +- src/core/cheats/cheats.cpp | 14 ++-- src/core/core.cpp | 6 +- src/core/custom_tex_cache.cpp | 12 ++-- src/core/dumping/ffmpeg_backend.cpp | 2 +- src/core/file_sys/archive_extsavedata.cpp | 16 ++--- src/core/file_sys/archive_sdmc.cpp | 22 +++--- src/core/file_sys/archive_sdmcwriteonly.cpp | 2 +- .../file_sys/archive_source_sd_savedata.cpp | 10 +-- src/core/file_sys/archive_systemsavedata.cpp | 6 +- src/core/file_sys/cia_container.cpp | 2 +- src/core/file_sys/disk_archive.cpp | 6 +- src/core/file_sys/disk_archive.h | 10 +-- src/core/file_sys/layered_fs.cpp | 28 ++++---- src/core/file_sys/ncch_container.cpp | 40 +++++------ src/core/file_sys/ncch_container.h | 4 +- src/core/file_sys/path_parser.cpp | 10 +-- src/core/file_sys/romfs_reader.h | 6 +- src/core/file_sys/savedata_archive.cpp | 20 +++--- src/core/file_sys/seed_db.cpp | 14 ++-- src/core/file_sys/title_metadata.cpp | 4 +- src/core/frontend/applets/mii_selector.cpp | 2 +- src/core/hle/service/am/am.cpp | 68 +++++++++---------- src/core/hle/service/apt/apt.cpp | 6 +- src/core/hle/service/cecd/cecd.cpp | 2 +- src/core/hle/service/cfg/cfg.cpp | 2 +- src/core/hle/service/fs/archive.cpp | 22 +++--- src/core/hle/service/ptm/ptm.cpp | 6 +- src/core/hw/aes/key.cpp | 12 ++-- src/core/hw/rsa/rsa.cpp | 4 +- src/core/loader/3dsx.cpp | 6 +- src/core/loader/3dsx.h | 6 +- src/core/loader/elf.cpp | 2 +- src/core/loader/elf.h | 6 +- src/core/loader/loader.cpp | 8 +-- src/core/loader/loader.h | 6 +- src/core/loader/ncch.cpp | 2 +- src/core/loader/ncch.h | 6 +- src/core/movie.cpp | 8 +-- src/core/perf_stats.cpp | 4 +- src/core/savestate.cpp | 16 ++--- src/core/settings.cpp | 4 +- src/core/telemetry_session.cpp | 12 ++-- src/core/tracer/recorder.cpp | 2 +- src/dedicated_room/citra-room.cpp | 4 +- src/tests/core/file_sys/path_parser.cpp | 8 +-- .../renderer_opengl/gl_shader_disk_cache.cpp | 44 ++++++------ .../renderer_opengl/gl_shader_disk_cache.h | 14 ++-- .../post_processing_opengl.cpp | 20 +++--- .../renderer_vulkan/vk_pipeline_cache.cpp | 10 +-- 67 files changed, 384 insertions(+), 384 deletions(-) diff --git a/src/android/app/src/main/jni/config.cpp b/src/android/app/src/main/jni/config.cpp index 746c26e09..9a231433b 100644 --- a/src/android/app/src/main/jni/config.cpp +++ b/src/android/app/src/main/jni/config.cpp @@ -25,7 +25,7 @@ Config::Config() { // TODO: Don't hardcode the path; let the frontend decide where to put the config files. - sdl2_config_loc = FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "config.ini"; + sdl2_config_loc = Common::FS::GetUserPath(Common::FS::UserPath::ConfigDir) + "config.ini"; sdl2_config = std::make_unique(sdl2_config_loc); Reload(); @@ -38,8 +38,8 @@ bool Config::LoadINI(const std::string& default_contents, bool retry) { if (sdl2_config->ParseError() < 0) { if (retry) { LOG_WARNING(Config, "Failed to load {}. Creating file from defaults...", location); - FileUtil::CreateFullPath(location); - FileUtil::WriteStringToFile(true, location, default_contents); + Common::FS::CreateFullPath(location); + Common::FS::WriteStringToFile(true, location, default_contents); sdl2_config = std::make_unique(location); // Reopen file return LoadINI(default_contents, false); diff --git a/src/android/app/src/main/jni/game_info.cpp b/src/android/app/src/main/jni/game_info.cpp index 80c0379d6..047176ffa 100644 --- a/src/android/app/src/main/jni/game_info.cpp +++ b/src/android/app/src/main/jni/game_info.cpp @@ -35,7 +35,7 @@ std::vector GetSMDHData(std::string physical_name) { std::string update_path = Service::AM::GetTitleContentPath( Service::FS::MediaType::SDMC, program_id + 0x0000000E'00000000); - if (!FileUtil::Exists(update_path)) + if (!Common::FS::Exists(update_path)) return original_smdh; std::unique_ptr update_loader = Loader::GetLoader(update_path); diff --git a/src/android/app/src/main/jni/id_cache.cpp b/src/android/app/src/main/jni/id_cache.cpp index 60c091912..e85405395 100644 --- a/src/android/app/src/main/jni/id_cache.cpp +++ b/src/android/app/src/main/jni/id_cache.cpp @@ -159,9 +159,9 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) { log_filter.ParseFilterString(Settings::values.log_filter); Log::SetGlobalFilter(log_filter); Log::AddBackend(std::make_unique()); - FileUtil::CreateFullPath(FileUtil::GetUserPath(FileUtil::UserPath::LogDir)); + Common::FS::CreateFullPath(Common::FS::GetUserPath(Common::FS::UserPath::LogDir)); Log::AddBackend(std::make_unique( - FileUtil::GetUserPath(FileUtil::UserPath::LogDir) + LOG_FILE)); + Common::FS::GetUserPath(Common::FS::UserPath::LogDir) + LOG_FILE)); LOG_INFO(Frontend, "Logging backend initialised"); // Initialize misc classes diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index d2c0f1d34..8016b1624 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -154,7 +154,7 @@ static Core::System::ResultStatus RunCitra(const std::string& filepath) { Config{}; // Replace with game-specific settings u64 program_id{}; - FileUtil::SetCurrentRomPath(filepath); + Common::FS::SetCurrentRomPath(filepath); auto app_loader = Loader::GetLoader(filepath); if (app_loader) { app_loader->ReadProgramId(program_id); @@ -305,18 +305,18 @@ void Java_org_citra_citra_1emu_NativeLibrary_SwapScreens(JNIEnv* env, [[maybe_un void Java_org_citra_citra_1emu_NativeLibrary_SetUserDirectory(JNIEnv* env, [[maybe_unused]] jclass clazz, jstring j_directory) { - FileUtil::SetCurrentDir(GetJString(env, j_directory)); + Common::FS::SetCurrentDir(GetJString(env, j_directory)); } jobjectArray Java_org_citra_citra_1emu_NativeLibrary_GetInstalledGamePaths( JNIEnv* env, [[maybe_unused]] jclass clazz) { std::vector games; - const FileUtil::DirectoryEntryCallable ScanDir = + const Common::FS::DirectoryEntryCallable ScanDir = [&games, &ScanDir](u64*, const std::string& directory, const std::string& virtual_name) { std::string path = directory + virtual_name; - if (FileUtil::IsDirectory(path)) { + if (Common::FS::IsDirectory(path)) { path += '/'; - FileUtil::ForeachDirectoryEntry(nullptr, path, ScanDir); + Common::FS::ForeachDirectoryEntry(nullptr, path, ScanDir); } else { auto loader = Loader::GetLoader(path); if (loader) { @@ -330,12 +330,12 @@ jobjectArray Java_org_citra_citra_1emu_NativeLibrary_GetInstalledGamePaths( return true; }; ScanDir(nullptr, "", - FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir) + + Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir) + "Nintendo " "3DS/00000000000000000000000000000000/" "00000000000000000000000000000000/title/00040000"); ScanDir(nullptr, "", - FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + + Common::FS::GetUserPath(Common::FS::UserPath::NANDDir) + "00000000000000000000000000000000/title/00040010"); jobjectArray jgames = env->NewObjectArray(static_cast(games.size()), env->FindClass("java/lang/String"), nullptr); diff --git a/src/audio_core/hle/ffmpeg_dl.cpp b/src/audio_core/hle/ffmpeg_dl.cpp index 073d0aedd..7a93f369b 100644 --- a/src/audio_core/hle/ffmpeg_dl.cpp +++ b/src/audio_core/hle/ffmpeg_dl.cpp @@ -43,8 +43,8 @@ FuncDL av_parser_close_dl; bool InitFFmpegDL() { - std::string dll_path = FileUtil::GetUserPath(FileUtil::UserPath::DLLDir); - FileUtil::CreateDir(dll_path); + std::string dll_path = Common::FS::GetUserPath(Common::FS::UserPath::DLLDir); + Common::FS::CreateDir(dll_path); std::wstring w_dll_path = Common::UTF8ToUTF16W(dll_path); SetDllDirectoryW(w_dll_path.c_str()); diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp index 9c816ef87..663e4933b 100644 --- a/src/citra/citra.cpp +++ b/src/citra/citra.cpp @@ -170,8 +170,8 @@ static void InitializeLogging() { Log::AddBackend(std::make_unique()); - const std::string& log_dir = FileUtil::GetUserPath(FileUtil::UserPath::LogDir); - FileUtil::CreateFullPath(log_dir); + const std::string& log_dir = Common::FS::GetUserPath(Common::FS::UserPath::LogDir); + Common::FS::CreateFullPath(log_dir); Log::AddBackend(std::make_unique(log_dir + LOG_FILE)); #ifdef _WIN32 Log::AddBackend(std::make_unique()); diff --git a/src/citra/config.cpp b/src/citra/config.cpp index d0ab6337a..482f6400a 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -22,7 +22,7 @@ Config::Config() { // TODO: Don't hardcode the path; let the frontend decide where to put the config files. - sdl2_config_loc = FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "sdl2-config.ini"; + sdl2_config_loc = Common::FS::GetUserPath(Common::FS::UserPath::ConfigDir) + "sdl2-config.ini"; sdl2_config = std::make_unique(sdl2_config_loc); Reload(); @@ -35,8 +35,8 @@ bool Config::LoadINI(const std::string& default_contents, bool retry) { if (sdl2_config->ParseError() < 0) { if (retry) { LOG_WARNING(Config, "Failed to load {}. Creating file from defaults...", location); - FileUtil::CreateFullPath(location); - FileUtil::WriteStringToFile(true, location, default_contents); + Common::FS::CreateFullPath(location); + Common::FS::WriteStringToFile(true, location, default_contents); sdl2_config = std::make_unique(location); // Reopen file return LoadINI(default_contents, false); @@ -208,9 +208,9 @@ void Config::ReadValues() { sdl2_config->GetBoolean("Data Storage", "use_custom_storage", false); if (Settings::values.use_custom_storage) { - FileUtil::UpdateUserPath(FileUtil::UserPath::NANDDir, + Common::FS::UpdateUserPath(Common::FS::UserPath::NANDDir, sdl2_config->GetString("Data Storage", "nand_directory", "")); - FileUtil::UpdateUserPath(FileUtil::UserPath::SDMCDir, + Common::FS::UpdateUserPath(Common::FS::UserPath::SDMCDir, sdl2_config->GetString("Data Storage", "sdmc_directory", "")); } diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index 5163a16b0..7d86b7652 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -19,8 +19,8 @@ Config::Config() { // TODO: Don't hardcode the path; let the frontend decide where to put the config files. - qt_config_loc = FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "qt-config.ini"; - FileUtil::CreateFullPath(qt_config_loc); + qt_config_loc = Common::FS::GetUserPath(Common::FS::UserPath::ConfigDir) + "qt-config.ini"; + Common::FS::CreateFullPath(qt_config_loc); qt_config = std::make_unique(QString::fromStdString(qt_config_loc), QSettings::IniFormat); Reload(); @@ -312,8 +312,8 @@ void Config::ReadDataStorageValues() { ReadSetting(QStringLiteral("sdmc_directory"), QStringLiteral("")).toString().toStdString(); if (Settings::values.use_custom_storage) { - FileUtil::UpdateUserPath(FileUtil::UserPath::NANDDir, nand_dir); - FileUtil::UpdateUserPath(FileUtil::UserPath::SDMCDir, sdmc_dir); + Common::FS::UpdateUserPath(Common::FS::UserPath::NANDDir, nand_dir); + Common::FS::UpdateUserPath(Common::FS::UserPath::SDMCDir, sdmc_dir); } qt_config->endGroup(); @@ -875,10 +875,10 @@ void Config::SaveDataStorageValues() { WriteSetting(QStringLiteral("use_virtual_sd"), Settings::values.use_virtual_sd, true); WriteSetting(QStringLiteral("use_custom_storage"), Settings::values.use_custom_storage, false); WriteSetting(QStringLiteral("nand_directory"), - QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)), + QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::NANDDir)), QStringLiteral("")); WriteSetting(QStringLiteral("sdmc_directory"), - QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)), + QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir)), QStringLiteral("")); qt_config->endGroup(); diff --git a/src/citra_qt/configuration/configure_debug.cpp b/src/citra_qt/configuration/configure_debug.cpp index f98051662..d4cd302fd 100644 --- a/src/citra_qt/configuration/configure_debug.cpp +++ b/src/citra_qt/configuration/configure_debug.cpp @@ -22,7 +22,7 @@ ConfigureDebug::ConfigureDebug(QWidget* parent) SetConfiguration(); connect(ui->open_log_button, &QPushButton::clicked, []() { - QString path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::LogDir)); + QString path = QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::LogDir)); QDesktopServices::openUrl(QUrl::fromLocalFile(path)); }); diff --git a/src/citra_qt/configuration/configure_general.cpp b/src/citra_qt/configuration/configure_general.cpp index 8fd404c80..b39784bbe 100644 --- a/src/citra_qt/configuration/configure_general.cpp +++ b/src/citra_qt/configuration/configure_general.cpp @@ -117,9 +117,9 @@ void ConfigureGeneral::SetConfiguration() { QString screenshot_path = UISettings::values.screenshot_path; if (screenshot_path.isEmpty()) { screenshot_path = - QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::UserDir)); + QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::UserDir)); screenshot_path.append(QStringLiteral("screenshots/")); - FileUtil::CreateFullPath(screenshot_path.toStdString()); + Common::FS::CreateFullPath(screenshot_path.toStdString()); UISettings::values.screenshot_path = screenshot_path; } ui->screenshot_dir_path->setText(screenshot_path); @@ -134,7 +134,7 @@ void ConfigureGeneral::ResetDefaults() { if (answer == QMessageBox::No) return; - FileUtil::Delete(FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + "qt-config.ini"); + Common::FS::Delete(Common::FS::GetUserPath(Common::FS::UserPath::ConfigDir) + "qt-config.ini"); std::exit(0); } diff --git a/src/citra_qt/configuration/configure_storage.cpp b/src/citra_qt/configuration/configure_storage.cpp index 043254350..b5bfbd406 100644 --- a/src/citra_qt/configuration/configure_storage.cpp +++ b/src/citra_qt/configuration/configure_storage.cpp @@ -16,33 +16,33 @@ ConfigureStorage::ConfigureStorage(QWidget* parent) SetConfiguration(); connect(ui->open_nand_dir, &QPushButton::clicked, []() { - QString path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)); + QString path = QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::NANDDir)); QDesktopServices::openUrl(QUrl::fromLocalFile(path)); }); connect(ui->change_nand_dir, &QPushButton::clicked, this, [this]() { const QString dir_path = QFileDialog::getExistingDirectory( this, tr("Select NAND Directory"), - QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)), + QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::NANDDir)), QFileDialog::ShowDirsOnly); if (!dir_path.isEmpty()) { - FileUtil::UpdateUserPath(FileUtil::UserPath::NANDDir, dir_path.toStdString()); + Common::FS::UpdateUserPath(Common::FS::UserPath::NANDDir, dir_path.toStdString()); SetConfiguration(); } }); connect(ui->open_sdmc_dir, &QPushButton::clicked, []() { - QString path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)); + QString path = QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir)); QDesktopServices::openUrl(QUrl::fromLocalFile(path)); }); connect(ui->change_sdmc_dir, &QPushButton::clicked, this, [this]() { const QString dir_path = QFileDialog::getExistingDirectory( this, tr("Select SDMC Directory"), - QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)), + QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir)), QFileDialog::ShowDirsOnly); if (!dir_path.isEmpty()) { - FileUtil::UpdateUserPath(FileUtil::UserPath::SDMCDir, dir_path.toStdString()); + Common::FS::UpdateUserPath(Common::FS::UserPath::SDMCDir, dir_path.toStdString()); SetConfiguration(); } }); @@ -61,13 +61,13 @@ ConfigureStorage::~ConfigureStorage() = default; void ConfigureStorage::SetConfiguration() { ui->nand_group->setVisible(Settings::values.use_custom_storage); - QString nand_path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)); + QString nand_path = QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::NANDDir)); ui->nand_dir_path->setText(nand_path); ui->open_nand_dir->setEnabled(!nand_path.isEmpty()); ui->sdmc_group->setVisible(Settings::values.use_virtual_sd && Settings::values.use_custom_storage); - QString sdmc_path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)); + QString sdmc_path = QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir)); ui->sdmc_dir_path->setText(sdmc_path); ui->open_sdmc_dir->setEnabled(!sdmc_path.isEmpty()); @@ -82,10 +82,10 @@ void ConfigureStorage::ApplyConfiguration() { Settings::values.use_custom_storage = ui->toggle_custom_storage->isChecked(); if (!Settings::values.use_custom_storage) { - FileUtil::UpdateUserPath(FileUtil::UserPath::NANDDir, - GetDefaultUserPath(FileUtil::UserPath::NANDDir)); - FileUtil::UpdateUserPath(FileUtil::UserPath::SDMCDir, - GetDefaultUserPath(FileUtil::UserPath::SDMCDir)); + Common::FS::UpdateUserPath(Common::FS::UserPath::NANDDir, + GetDefaultUserPath(Common::FS::UserPath::NANDDir)); + Common::FS::UpdateUserPath(Common::FS::UserPath::SDMCDir, + GetDefaultUserPath(Common::FS::UserPath::SDMCDir)); } } diff --git a/src/citra_qt/game_list.cpp b/src/citra_qt/game_list.cpp index f7f0561a8..99d0b2818 100644 --- a/src/citra_qt/game_list.cpp +++ b/src/citra_qt/game_list.cpp @@ -493,15 +493,15 @@ void GameList::AddGamePopup(QMenu& context_menu, const QString& path, u64 progra const bool is_application = 0x0004000000000000 <= program_id && program_id <= 0x00040000FFFFFFFF; - std::string sdmc_dir = FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir); + std::string sdmc_dir = Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir); open_save_location->setEnabled( - is_application && FileUtil::Exists(FileSys::ArchiveSource_SDSaveData::GetSaveDataPathFor( + is_application && Common::FS::Exists(FileSys::ArchiveSource_SDSaveData::GetSaveDataPathFor( sdmc_dir, program_id))); if (extdata_id) { open_extdata_location->setEnabled( is_application && - FileUtil::Exists(FileSys::GetExtDataPathFromId(sdmc_dir, extdata_id))); + Common::FS::Exists(FileSys::GetExtDataPathFromId(sdmc_dir, extdata_id))); } else { open_extdata_location->setVisible(false); } @@ -510,7 +510,7 @@ void GameList::AddGamePopup(QMenu& context_menu, const QString& path, u64 progra open_application_location->setEnabled(path.toStdString() == Service::AM::GetTitleContentPath(media_type, program_id)); open_update_location->setEnabled( - is_application && FileUtil::Exists(Service::AM::GetTitlePath(Service::FS::MediaType::SDMC, + is_application && Common::FS::Exists(Service::AM::GetTitlePath(Service::FS::MediaType::SDMC, program_id + 0xe00000000) + "content/")); auto it = FindMatchingCompatibilityEntry(compatibility_list, program_id); @@ -535,29 +535,29 @@ void GameList::AddGamePopup(QMenu& context_menu, const QString& path, u64 progra emit OpenFolderRequested(program_id, GameListOpenTarget::UPDATE_DATA); }); connect(open_texture_dump_location, &QAction::triggered, this, [this, program_id] { - if (FileUtil::CreateFullPath(fmt::format("{}textures/{:016X}/", - FileUtil::GetUserPath(FileUtil::UserPath::DumpDir), + if (Common::FS::CreateFullPath(fmt::format("{}textures/{:016X}/", + Common::FS::GetUserPath(Common::FS::UserPath::DumpDir), program_id))) { emit OpenFolderRequested(program_id, GameListOpenTarget::TEXTURE_DUMP); } }); connect(open_texture_load_location, &QAction::triggered, this, [this, program_id] { - if (FileUtil::CreateFullPath(fmt::format("{}textures/{:016X}/", - FileUtil::GetUserPath(FileUtil::UserPath::LoadDir), + if (Common::FS::CreateFullPath(fmt::format("{}textures/{:016X}/", + Common::FS::GetUserPath(Common::FS::UserPath::LoadDir), program_id))) { emit OpenFolderRequested(program_id, GameListOpenTarget::TEXTURE_LOAD); } }); connect(open_texture_load_location, &QAction::triggered, this, [this, program_id] { - if (FileUtil::CreateFullPath(fmt::format("{}textures/{:016X}/", - FileUtil::GetUserPath(FileUtil::UserPath::LoadDir), + if (Common::FS::CreateFullPath(fmt::format("{}textures/{:016X}/", + Common::FS::GetUserPath(Common::FS::UserPath::LoadDir), program_id))) { emit OpenFolderRequested(program_id, GameListOpenTarget::TEXTURE_LOAD); } }); connect(open_mods_location, &QAction::triggered, this, [this, program_id] { - if (FileUtil::CreateFullPath(fmt::format("{}mods/{:016X}/", - FileUtil::GetUserPath(FileUtil::UserPath::LoadDir), + if (Common::FS::CreateFullPath(fmt::format("{}mods/{:016X}/", + Common::FS::GetUserPath(Common::FS::UserPath::LoadDir), program_id))) { emit OpenFolderRequested(program_id, GameListOpenTarget::MODS); } @@ -568,7 +568,7 @@ void GameList::AddGamePopup(QMenu& context_menu, const QString& path, u64 progra emit NavigateToGamedbEntryRequested(program_id, compatibility_list); }); connect(open_shader_cache_location, &QAction::triggered, this, [this, program_id] { - if (FileUtil::CreateFullPath(FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir))) { + if (Common::FS::CreateFullPath(Common::FS::GetUserPath(Common::FS::UserPath::ShaderDir))) { emit OpenFolderRequested(program_id, GameListOpenTarget::SHADER_CACHE); } }); @@ -576,14 +576,14 @@ void GameList::AddGamePopup(QMenu& context_menu, const QString& path, u64 progra const std::string_view cache_type = Settings::values.separable_shader ? "separable" : "conventional"; const std::string path = fmt::format("{}opengl/precompiled/{}/{:016X}.bin", - FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir), + Common::FS::GetUserPath(Common::FS::UserPath::ShaderDir), cache_type, program_id); QFile file{QString::fromStdString(path)}; file.remove(); }); connect(delete_vulkan_disk_shader_cache, &QAction::triggered, this, [] { const std::string path = - fmt::format("{}vulkan", FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir)); + fmt::format("{}vulkan", Common::FS::GetUserPath(Common::FS::UserPath::ShaderDir)); QDir dir{QString::fromStdString(path)}; dir.removeRecursively(); }); diff --git a/src/citra_qt/game_list_worker.cpp b/src/citra_qt/game_list_worker.cpp index 5f73a901c..14670d1dd 100644 --- a/src/citra_qt/game_list_worker.cpp +++ b/src/citra_qt/game_list_worker.cpp @@ -43,7 +43,7 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign } const std::string physical_name = directory + DIR_SEP + virtual_name; - const bool is_dir = FileUtil::IsDirectory(physical_name); + const bool is_dir = Common::FS::IsDirectory(physical_name); if (!is_dir && HasSupportedFileExtension(physical_name)) { std::unique_ptr loader = Loader::GetLoader(physical_name); if (!loader) { @@ -67,7 +67,7 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign if (!(program_id & ~0x00040000FFFFFFFF)) { std::string update_path = Service::AM::GetTitleContentPath( Service::FS::MediaType::SDMC, program_id | 0x0000000E00000000); - if (FileUtil::Exists(update_path)) { + if (Common::FS::Exists(update_path)) { std::unique_ptr update_loader = Loader::GetLoader(update_path); if (update_loader) { @@ -101,7 +101,7 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign new GameListItemRegion(smdh), new GameListItem( QString::fromStdString(Loader::GetFileTypeString(loader->GetFileType()))), - new GameListItemSize(FileUtil::GetSize(physical_name)), + new GameListItemSize(Common::FS::GetSize(physical_name)), }, parent_dir); @@ -113,7 +113,7 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign return true; }; - FileUtil::ForeachDirectoryEntry(nullptr, dir_path, callback); + Common::FS::ForeachDirectoryEntry(nullptr, dir_path, callback); } void GameListWorker::run() { @@ -121,12 +121,12 @@ void GameListWorker::run() { for (UISettings::GameDir& game_dir : game_dirs) { if (game_dir.path == QStringLiteral("INSTALLED")) { QString games_path = - QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)) + + QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir)) + QStringLiteral("Nintendo " "3DS/00000000000000000000000000000000/" "00000000000000000000000000000000/title/00040000"); QString demos_path = - QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)) + + QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir)) + QStringLiteral( "Nintendo " "3DS/00000000000000000000000000000000/00000000000000000000000000000000/title/" @@ -139,7 +139,7 @@ void GameListWorker::run() { AddFstEntriesToGameList(demos_path.toStdString(), 2, game_list_dir); } else if (game_dir.path == QStringLiteral("SYSTEM")) { QString path = - QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)) + + QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::NANDDir)) + QStringLiteral("00000000000000000000000000000000/title/00040010"); watch_list.append(path); auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SystemDir); diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 6b18f75d3..47eac91cb 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -138,8 +138,8 @@ static void InitializeLogging() { log_filter.ParseFilterString(Settings::values.log_filter); Log::SetGlobalFilter(log_filter); - const std::string& log_dir = FileUtil::GetUserPath(FileUtil::UserPath::LogDir); - FileUtil::CreateFullPath(log_dir); + const std::string& log_dir = Common::FS::GetUserPath(Common::FS::UserPath::LogDir); + Common::FS::CreateFullPath(log_dir); Log::AddBackend(std::make_unique(log_dir + LOG_FILE)); #ifdef _WIN32 Log::AddBackend(std::make_unique()); @@ -1324,13 +1324,13 @@ void GMainWindow::OnGameListOpenFolder(u64 data_id, GameListOpenTarget target) { switch (target) { case GameListOpenTarget::SAVE_DATA: { open_target = "Save Data"; - std::string sdmc_dir = FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir); + std::string sdmc_dir = Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir); path = FileSys::ArchiveSource_SDSaveData::GetSaveDataPathFor(sdmc_dir, data_id); break; } case GameListOpenTarget::EXT_DATA: { open_target = "Extra Data"; - std::string sdmc_dir = FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir); + std::string sdmc_dir = Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir); path = FileSys::GetExtDataPathFromId(sdmc_dir, data_id); break; } @@ -1349,24 +1349,24 @@ void GMainWindow::OnGameListOpenFolder(u64 data_id, GameListOpenTarget target) { case GameListOpenTarget::TEXTURE_DUMP: { open_target = "Dumped Textures"; path = fmt::format("{}textures/{:016X}/", - FileUtil::GetUserPath(FileUtil::UserPath::DumpDir), data_id); + Common::FS::GetUserPath(Common::FS::UserPath::DumpDir), data_id); break; } case GameListOpenTarget::TEXTURE_LOAD: { open_target = "Custom Textures"; path = fmt::format("{}textures/{:016X}/", - FileUtil::GetUserPath(FileUtil::UserPath::LoadDir), data_id); + Common::FS::GetUserPath(Common::FS::UserPath::LoadDir), data_id); break; } case GameListOpenTarget::MODS: { open_target = "Mods"; - path = fmt::format("{}mods/{:016X}/", FileUtil::GetUserPath(FileUtil::UserPath::LoadDir), + path = fmt::format("{}mods/{:016X}/", Common::FS::GetUserPath(Common::FS::UserPath::LoadDir), data_id); break; } case GameListOpenTarget::SHADER_CACHE: { open_target = "Shader Cache"; - path = FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir); + path = Common::FS::GetUserPath(Common::FS::UserPath::ShaderDir); break; } default: @@ -1410,9 +1410,9 @@ void GMainWindow::OnGameListDumpRomFS(QString game_path, u64 program_id) { dialog->setValue(0); const auto base_path = fmt::format( - "{}romfs/{:016X}", FileUtil::GetUserPath(FileUtil::UserPath::DumpDir), program_id); + "{}romfs/{:016X}", Common::FS::GetUserPath(Common::FS::UserPath::DumpDir), program_id); const auto update_path = - fmt::format("{}romfs/{:016X}", FileUtil::GetUserPath(FileUtil::UserPath::DumpDir), + fmt::format("{}romfs/{:016X}", Common::FS::GetUserPath(Common::FS::UserPath::DumpDir), program_id | 0x0004000e00000000); using FutureWatcher = QFutureWatcher>; auto* future_watcher = new FutureWatcher(this); @@ -1443,12 +1443,12 @@ void GMainWindow::OnGameListDumpRomFS(QString game_path, u64 program_id) { void GMainWindow::OnGameListOpenDirectory(const QString& directory) { QString path; if (directory == QStringLiteral("INSTALLED")) { - path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir) + + path = QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir) + "Nintendo " "3DS/00000000000000000000000000000000/" "00000000000000000000000000000000/title/00040000"); } else if (directory == QStringLiteral("SYSTEM")) { - path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir) + + path = QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::NANDDir) + "00000000000000000000000000000000/title/00040010"); } else { path = directory; @@ -1873,7 +1873,7 @@ void GMainWindow::OnRemoveAmiibo() { void GMainWindow::OnOpenCitraFolder() { QDesktopServices::openUrl(QUrl::fromLocalFile( - QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::UserDir)))); + QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::UserDir)))); } void GMainWindow::OnToggleFilterBar() { @@ -1973,12 +1973,12 @@ void GMainWindow::OnSaveMovie() { void GMainWindow::OnCaptureScreenshot() { OnPauseGame(); QString path = UISettings::values.screenshot_path; - if (!FileUtil::IsDirectory(path.toStdString())) { - if (!FileUtil::CreateFullPath(path.toStdString())) { + if (!Common::FS::IsDirectory(path.toStdString())) { + if (!Common::FS::CreateFullPath(path.toStdString())) { QMessageBox::information(this, tr("Invalid Screenshot Directory"), tr("Cannot create specified screenshot directory. Screenshot " "path is set back to its default value.")); - path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::UserDir)); + path = QString::fromStdString(Common::FS::GetUserPath(Common::FS::UserPath::UserDir)); path.append(QStringLiteral("screenshots/")); UISettings::values.screenshot_path = path; }; @@ -2482,7 +2482,7 @@ int main(int argc, char* argv[]) { QCoreApplication::setApplicationName(QStringLiteral("Citra")); #ifdef __APPLE__ - std::string bin_path = FileUtil::GetBundleDirectory() + DIR_SEP + ".."; + std::string bin_path = Common::FS::GetBundleDirectory() + DIR_SEP + ".."; chdir(bin_path.c_str()); #endif QCoreApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity); diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp index 73c606972..7b02c0230 100644 --- a/src/common/file_util.cpp +++ b/src/common/file_util.cpp @@ -76,7 +76,7 @@ // This namespace has various generic functions related to files and paths. // The code still needs a ton of cleanup. // REMEMBER: strdup considered harmful! -namespace FileUtil { +namespace Common::FS { // Remove any ending forward slashes from directory paths // Modifies argument. @@ -198,7 +198,7 @@ bool CreateFullPath(const std::string& fullPath) { int panicCounter = 100; LOG_TRACE(Common_Filesystem, "path {}", fullPath); - if (FileUtil::Exists(fullPath)) { + if (Common::FS::Exists(fullPath)) { LOG_DEBUG(Common_Filesystem, "path exists {}", fullPath); return true; } @@ -214,7 +214,7 @@ bool CreateFullPath(const std::string& fullPath) { // Include the '/' so the first call is CreateDir("/") rather than CreateDir("") std::string const subPath(fullPath.substr(0, position + 1)); - if (!FileUtil::IsDirectory(subPath) && !FileUtil::CreateDir(subPath)) { + if (!Common::FS::IsDirectory(subPath) && !Common::FS::CreateDir(subPath)) { LOG_ERROR(Common, "CreateFullPath: directory creation failed"); return false; } @@ -233,7 +233,7 @@ bool DeleteDir(const std::string& filename) { LOG_TRACE(Common_Filesystem, "directory {}", filename); // check if a directory - if (!FileUtil::IsDirectory(filename)) { + if (!Common::FS::IsDirectory(filename)) { LOG_ERROR(Common_Filesystem, "Not a directory {}", filename); return false; } @@ -373,7 +373,7 @@ u64 GetSize(FILE* f) { bool CreateEmptyFile(const std::string& filename) { LOG_TRACE(Common_Filesystem, "{}", filename); - if (!FileUtil::IOFile(filename, "wb").IsOpen()) { + if (!Common::FS::IOFile(filename, "wb").IsOpen()) { LOG_ERROR(Common_Filesystem, "failed {}: {}", filename, GetLastErrorMsg()); return false; } @@ -501,7 +501,7 @@ bool DeleteDirRecursively(const std::string& directory, unsigned int recursion) return false; // Delete the outermost directory - FileUtil::DeleteDir(directory); + Common::FS::DeleteDir(directory); return true; } @@ -509,10 +509,10 @@ void CopyDir(const std::string& source_path, const std::string& dest_path) { #ifndef _WIN32 if (source_path == dest_path) return; - if (!FileUtil::Exists(source_path)) + if (!Common::FS::Exists(source_path)) return; - if (!FileUtil::Exists(dest_path)) - FileUtil::CreateFullPath(dest_path); + if (!Common::FS::Exists(dest_path)) + Common::FS::CreateFullPath(dest_path); DIR* dirp = opendir(source_path.c_str()); if (!dirp) @@ -531,11 +531,11 @@ void CopyDir(const std::string& source_path, const std::string& dest_path) { if (IsDirectory(source)) { source += '/'; dest += '/'; - if (!FileUtil::Exists(dest)) - FileUtil::CreateFullPath(dest); + if (!Common::FS::Exists(dest)) + Common::FS::CreateFullPath(dest); CopyDir(source, dest); - } else if (!FileUtil::Exists(dest)) - FileUtil::Copy(source, dest); + } else if (!Common::FS::Exists(dest)) + Common::FS::Copy(source, dest); } closedir(dirp); #endif @@ -560,7 +560,7 @@ std::optional GetCurrentDir() { #endif free(dir); return strDir; -} // namespace FileUtil +} // namespace Common::FS bool SetCurrentDir(const std::string& directory) { #ifdef _WIN32 @@ -689,7 +689,7 @@ void SetUserPath(const std::string& path) { } else { #ifdef _WIN32 user_path = GetExeDirectory() + DIR_SEP USERDATA_DIR DIR_SEP; - if (!FileUtil::IsDirectory(user_path)) { + if (!Common::FS::IsDirectory(user_path)) { user_path = AppDataRoamingDirectory() + DIR_SEP EMU_DATA_DIR DIR_SEP; } else { LOG_INFO(Common_Filesystem, "Using the local user directory"); @@ -698,13 +698,13 @@ void SetUserPath(const std::string& path) { g_paths.emplace(UserPath::ConfigDir, user_path + CONFIG_DIR DIR_SEP); g_paths.emplace(UserPath::CacheDir, user_path + CACHE_DIR DIR_SEP); #elif ANDROID - if (FileUtil::Exists(DIR_SEP SDCARD_DIR)) { + if (Common::FS::Exists(DIR_SEP SDCARD_DIR)) { user_path = DIR_SEP SDCARD_DIR DIR_SEP EMU_DATA_DIR DIR_SEP; g_paths.emplace(UserPath::ConfigDir, user_path + CONFIG_DIR DIR_SEP); g_paths.emplace(UserPath::CacheDir, user_path + CACHE_DIR DIR_SEP); } #else - if (FileUtil::Exists(ROOT_DIR DIR_SEP USERDATA_DIR)) { + if (Common::FS::Exists(ROOT_DIR DIR_SEP USERDATA_DIR)) { user_path = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP; g_paths.emplace(UserPath::ConfigDir, user_path + CONFIG_DIR DIR_SEP); g_paths.emplace(UserPath::CacheDir, user_path + CACHE_DIR DIR_SEP); @@ -779,7 +779,7 @@ const void UpdateUserPath(UserPath path, const std::string& filename) { if (filename.empty()) { return; } - if (!FileUtil::IsDirectory(filename)) { + if (!Common::FS::IsDirectory(filename)) { LOG_ERROR(Common_Filesystem, "Path is not a directory. UserPath: {} filename: {}", path, filename); return; @@ -998,7 +998,7 @@ bool IOFile::Close() { u64 IOFile::GetSize() const { if (IsOpen()) - return FileUtil::GetSize(m_file); + return Common::FS::GetSize(m_file); return 0; } @@ -1070,4 +1070,4 @@ bool IOFile::Resize(u64 size) { return m_good; } -} // namespace FileUtil +} // namespace Common::FS diff --git a/src/common/file_util.h b/src/common/file_util.h index cdd55b665..85f0b37dd 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h @@ -22,7 +22,7 @@ #include "common/string_util.h" #endif -namespace FileUtil { +namespace Common::FS { // User paths for GetUserPath enum class UserPath { @@ -383,7 +383,7 @@ private: friend class boost::serialization::access; }; -} // namespace FileUtil +} // namespace Common::FS // To deal with Windows being dumb at unicode: template diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 56df7d9e2..c0c7d6a83 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -145,16 +145,16 @@ void LogcatBackend::Write(const Entry& entry) { } FileBackend::FileBackend(const std::string& filename) : bytes_written(0) { - if (FileUtil::Exists(filename + ".old.txt")) { - FileUtil::Delete(filename + ".old.txt"); + if (Common::FS::Exists(filename + ".old.txt")) { + Common::FS::Delete(filename + ".old.txt"); } - if (FileUtil::Exists(filename)) { - FileUtil::Rename(filename, filename + ".old.txt"); + if (Common::FS::Exists(filename)) { + Common::FS::Rename(filename, filename + ".old.txt"); } // _SH_DENYWR allows read only access to the file for other programs. // It is #defined to 0 on other platforms - file = FileUtil::IOFile(filename, "w", _SH_DENYWR); + file = Common::FS::IOFile(filename, "w", _SH_DENYWR); } void FileBackend::Write(const Entry& entry) { diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h index 907c6a297..e188d200b 100644 --- a/src/common/logging/backend.h +++ b/src/common/logging/backend.h @@ -114,7 +114,7 @@ public: void Write(const Entry& entry) override; private: - FileUtil::IOFile file; + Common::FS::IOFile file; std::size_t bytes_written; }; diff --git a/src/core/cheats/cheats.cpp b/src/core/cheats/cheats.cpp index 440047ffe..1be7e95e5 100644 --- a/src/core/cheats/cheats.cpp +++ b/src/core/cheats/cheats.cpp @@ -64,12 +64,12 @@ void CheatEngine::UpdateCheat(int index, const std::shared_ptr& new_c } void CheatEngine::SaveCheatFile() const { - const std::string cheat_dir = FileUtil::GetUserPath(FileUtil::UserPath::CheatsDir); + const std::string cheat_dir = Common::FS::GetUserPath(Common::FS::UserPath::CheatsDir); const std::string filepath = fmt::format( "{}{:016X}.txt", cheat_dir, system.Kernel().GetCurrentProcess()->codeset->program_id); - if (!FileUtil::IsDirectory(cheat_dir)) { - FileUtil::CreateDir(cheat_dir); + if (!Common::FS::IsDirectory(cheat_dir)) { + Common::FS::CreateDir(cheat_dir); } std::ofstream file; @@ -84,15 +84,15 @@ void CheatEngine::SaveCheatFile() const { } void CheatEngine::LoadCheatFile() { - const std::string cheat_dir = FileUtil::GetUserPath(FileUtil::UserPath::CheatsDir); + const std::string cheat_dir = Common::FS::GetUserPath(Common::FS::UserPath::CheatsDir); const std::string filepath = fmt::format( "{}{:016X}.txt", cheat_dir, system.Kernel().GetCurrentProcess()->codeset->program_id); - if (!FileUtil::IsDirectory(cheat_dir)) { - FileUtil::CreateDir(cheat_dir); + if (!Common::FS::IsDirectory(cheat_dir)) { + Common::FS::CreateDir(cheat_dir); } - if (!FileUtil::Exists(filepath)) + if (!Common::FS::Exists(filepath)) return; auto gateway_cheats = GatewayCheat::LoadFile(filepath); diff --git a/src/core/core.cpp b/src/core/core.cpp index 8450bb0a8..c248addae 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -248,7 +248,7 @@ System::ResultStatus System::SingleStep() { } System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::string& filepath) { - FileUtil::SetCurrentRomPath(filepath); + Common::FS::SetCurrentRomPath(filepath); app_loader = Loader::GetLoader(filepath); if (!app_loader) { LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); @@ -314,8 +314,8 @@ System::ResultStatus System::Load(Frontend::EmuWindow& emu_window, const std::st if (Settings::values.custom_textures) { const u64 program_id = Kernel().GetCurrentProcess()->codeset->program_id; - FileUtil::CreateFullPath(fmt::format( - "{}textures/{:016X}/", FileUtil::GetUserPath(FileUtil::UserPath::LoadDir), program_id)); + Common::FS::CreateFullPath(fmt::format( + "{}textures/{:016X}/", Common::FS::GetUserPath(Common::FS::UserPath::LoadDir), program_id)); custom_tex_cache->FindCustomTextures(program_id); } if (Settings::values.preload_textures) { diff --git a/src/core/custom_tex_cache.cpp b/src/core/custom_tex_cache.cpp index 9045df836..0b43afbd1 100644 --- a/src/core/custom_tex_cache.cpp +++ b/src/core/custom_tex_cache.cpp @@ -45,14 +45,14 @@ void CustomTexCache::FindCustomTextures(u64 program_id) { // [TitleID]/tex1_[width]x[height]_[64-bit hash]_[format].png const std::string load_path = fmt::format( - "{}textures/{:016X}/", FileUtil::GetUserPath(FileUtil::UserPath::LoadDir), program_id); + "{}textures/{:016X}/", Common::FS::GetUserPath(Common::FS::UserPath::LoadDir), program_id); - if (FileUtil::Exists(load_path)) { - FileUtil::FSTEntry texture_dir; - std::vector textures; + if (Common::FS::Exists(load_path)) { + Common::FS::FSTEntry texture_dir; + std::vector textures; // 64 nested folders should be plenty for most cases - FileUtil::ScanDirectoryTree(load_path, texture_dir, 64); - FileUtil::GetAllFilesFromNestedEntries(texture_dir, textures); + Common::FS::ScanDirectoryTree(load_path, texture_dir, 64); + Common::FS::GetAllFilesFromNestedEntries(texture_dir, textures); for (const auto& file : textures) { if (file.isDirectory) diff --git a/src/core/dumping/ffmpeg_backend.cpp b/src/core/dumping/ffmpeg_backend.cpp index cad321d87..716091f6e 100644 --- a/src/core/dumping/ffmpeg_backend.cpp +++ b/src/core/dumping/ffmpeg_backend.cpp @@ -412,7 +412,7 @@ bool FFmpegMuxer::Init(const std::string& path, const Layout::FramebufferLayout& InitializeFFmpegLibraries(); - if (!FileUtil::CreateFullPath(path)) { + if (!Common::FS::CreateFullPath(path)) { return false; } diff --git a/src/core/file_sys/archive_extsavedata.cpp b/src/core/file_sys/archive_extsavedata.cpp index 65ad8490e..4210880bd 100644 --- a/src/core/file_sys/archive_extsavedata.cpp +++ b/src/core/file_sys/archive_extsavedata.cpp @@ -30,7 +30,7 @@ namespace FileSys { */ class FixSizeDiskFile : public DiskFile { public: - FixSizeDiskFile(FileUtil::IOFile&& file, const Mode& mode, + FixSizeDiskFile(Common::FS::IOFile&& file, const Mode& mode, std::unique_ptr delay_generator_) : DiskFile(std::move(file), mode, std::move(delay_generator_)) { size = GetSize(); @@ -144,7 +144,7 @@ public: break; // Expected 'success' case } - FileUtil::IOFile file(full_path, "r+b"); + Common::FS::IOFile file(full_path, "r+b"); if (!file.IsOpen()) { LOG_CRITICAL(Service_FS, "(unreachable) Unknown error opening {}", full_path); return ERROR_FILE_NOT_FOUND; @@ -248,7 +248,7 @@ Path ArchiveFactory_ExtSaveData::GetCorrectedPath(const Path& path) { ResultVal> ArchiveFactory_ExtSaveData::Open(const Path& path, u64 program_id) { std::string fullpath = GetExtSaveDataPath(mount_point, GetCorrectedPath(path)) + "user/"; - if (!FileUtil::Exists(fullpath)) { + if (!Common::FS::Exists(fullpath)) { // TODO(Subv): Verify the archive behavior of SharedExtSaveData compared to ExtSaveData. // ExtSaveData seems to return FS_NotFound (120) when the archive doesn't exist. if (!shared) { @@ -270,12 +270,12 @@ ResultCode ArchiveFactory_ExtSaveData::Format(const Path& path, // These folders are always created with the ExtSaveData std::string user_path = GetExtSaveDataPath(mount_point, corrected_path) + "user/"; std::string boss_path = GetExtSaveDataPath(mount_point, corrected_path) + "boss/"; - FileUtil::CreateFullPath(user_path); - FileUtil::CreateFullPath(boss_path); + Common::FS::CreateFullPath(user_path); + Common::FS::CreateFullPath(boss_path); // Write the format metadata std::string metadata_path = GetExtSaveDataPath(mount_point, corrected_path) + "metadata"; - FileUtil::IOFile file(metadata_path, "wb"); + Common::FS::IOFile file(metadata_path, "wb"); if (!file.IsOpen()) { // TODO(Subv): Find the correct error code @@ -289,7 +289,7 @@ ResultCode ArchiveFactory_ExtSaveData::Format(const Path& path, ResultVal ArchiveFactory_ExtSaveData::GetFormatInfo(const Path& path, u64 program_id) const { std::string metadata_path = GetExtSaveDataPath(mount_point, path) + "metadata"; - FileUtil::IOFile file(metadata_path, "rb"); + Common::FS::IOFile file(metadata_path, "rb"); if (!file.IsOpen()) { LOG_ERROR(Service_FS, "Could not open metadata information for archive"); @@ -305,7 +305,7 @@ ResultVal ArchiveFactory_ExtSaveData::GetFormatInfo(const Pat void ArchiveFactory_ExtSaveData::WriteIcon(const Path& path, const u8* icon_data, std::size_t icon_size) { std::string game_path = FileSys::GetExtSaveDataPath(GetMountPoint(), path); - FileUtil::IOFile icon_file(game_path + "icon", "wb"); + Common::FS::IOFile icon_file(game_path + "icon", "wb"); icon_file.WriteBytes(icon_data, icon_size); } diff --git a/src/core/file_sys/archive_sdmc.cpp b/src/core/file_sys/archive_sdmc.cpp index 4c3ce6d69..66c1d0a33 100644 --- a/src/core/file_sys/archive_sdmc.cpp +++ b/src/core/file_sys/archive_sdmc.cpp @@ -97,14 +97,14 @@ ResultVal> SDMCArchive::OpenFileBase(const Path& pa return ERROR_NOT_FOUND; } else { // Create the file - FileUtil::CreateEmptyFile(full_path); + Common::FS::CreateEmptyFile(full_path); } break; case PathParser::FileFound: break; // Expected 'success' case } - FileUtil::IOFile file(full_path, mode.write_flag ? "r+b" : "rb"); + Common::FS::IOFile file(full_path, mode.write_flag ? "r+b" : "rb"); if (!file.IsOpen()) { LOG_CRITICAL(Service_FS, "(unreachable) Unknown error opening {}", full_path); return ERROR_NOT_FOUND; @@ -141,7 +141,7 @@ ResultCode SDMCArchive::DeleteFile(const Path& path) const { break; // Expected 'success' case } - if (FileUtil::Delete(full_path)) { + if (Common::FS::Delete(full_path)) { return RESULT_SUCCESS; } @@ -168,7 +168,7 @@ ResultCode SDMCArchive::RenameFile(const Path& src_path, const Path& dest_path) const auto src_path_full = path_parser_src.BuildHostPath(mount_point); const auto dest_path_full = path_parser_dest.BuildHostPath(mount_point); - if (FileUtil::Rename(src_path_full, dest_path_full)) { + if (Common::FS::Rename(src_path_full, dest_path_full)) { return RESULT_SUCCESS; } @@ -218,12 +218,12 @@ static ResultCode DeleteDirectoryHelper(const Path& path, const std::string& mou } ResultCode SDMCArchive::DeleteDirectory(const Path& path) const { - return DeleteDirectoryHelper(path, mount_point, FileUtil::DeleteDir); + return DeleteDirectoryHelper(path, mount_point, Common::FS::DeleteDir); } ResultCode SDMCArchive::DeleteDirectoryRecursively(const Path& path) const { return DeleteDirectoryHelper( - path, mount_point, [](const std::string& p) { return FileUtil::DeleteDirRecursively(p); }); + path, mount_point, [](const std::string& p) { return Common::FS::DeleteDirRecursively(p); }); } ResultCode SDMCArchive::CreateFile(const FileSys::Path& path, u64 size) const { @@ -255,11 +255,11 @@ ResultCode SDMCArchive::CreateFile(const FileSys::Path& path, u64 size) const { } if (size == 0) { - FileUtil::CreateEmptyFile(full_path); + Common::FS::CreateEmptyFile(full_path); return RESULT_SUCCESS; } - FileUtil::IOFile file(full_path, "wb"); + Common::FS::IOFile file(full_path, "wb"); // Creates a sparse file (or a normal file on filesystems without the concept of sparse files) // We do this by seeking to the right size, then writing a single null byte. if (file.Seek(size - 1, SEEK_SET) && file.WriteBytes("", 1) == 1) { @@ -297,7 +297,7 @@ ResultCode SDMCArchive::CreateDirectory(const Path& path) const { break; // Expected 'success' case } - if (FileUtil::CreateDir(mount_point + path.AsString())) { + if (Common::FS::CreateDir(mount_point + path.AsString())) { return RESULT_SUCCESS; } @@ -325,7 +325,7 @@ ResultCode SDMCArchive::RenameDirectory(const Path& src_path, const Path& dest_p const auto src_path_full = path_parser_src.BuildHostPath(mount_point); const auto dest_path_full = path_parser_dest.BuildHostPath(mount_point); - if (FileUtil::Rename(src_path_full, dest_path_full)) { + if (Common::FS::Rename(src_path_full, dest_path_full)) { return RESULT_SUCCESS; } @@ -382,7 +382,7 @@ bool ArchiveFactory_SDMC::Initialize() { return false; } - if (!FileUtil::CreateFullPath(sdmc_directory)) { + if (!Common::FS::CreateFullPath(sdmc_directory)) { LOG_ERROR(Service_FS, "Unable to create SDMC path."); return false; } diff --git a/src/core/file_sys/archive_sdmcwriteonly.cpp b/src/core/file_sys/archive_sdmcwriteonly.cpp index 241e93f0a..03a291258 100644 --- a/src/core/file_sys/archive_sdmcwriteonly.cpp +++ b/src/core/file_sys/archive_sdmcwriteonly.cpp @@ -69,7 +69,7 @@ bool ArchiveFactory_SDMCWriteOnly::Initialize() { return false; } - if (!FileUtil::CreateFullPath(sdmc_directory)) { + if (!Common::FS::CreateFullPath(sdmc_directory)) { LOG_ERROR(Service_FS, "Unable to create SDMC path."); return false; } diff --git a/src/core/file_sys/archive_source_sd_savedata.cpp b/src/core/file_sys/archive_source_sd_savedata.cpp index 9afbfd73c..47b0039af 100644 --- a/src/core/file_sys/archive_source_sd_savedata.cpp +++ b/src/core/file_sys/archive_source_sd_savedata.cpp @@ -45,7 +45,7 @@ ArchiveSource_SDSaveData::ArchiveSource_SDSaveData(const std::string& sdmc_direc ResultVal> ArchiveSource_SDSaveData::Open(u64 program_id) { std::string concrete_mount_point = GetSaveDataPath(mount_point, program_id); - if (!FileUtil::Exists(concrete_mount_point)) { + if (!Common::FS::Exists(concrete_mount_point)) { // When a SaveData archive is created for the first time, it is not yet formatted and the // save file/directory structure expected by the game has not yet been initialized. // Returning the NotFormatted error code will signal the game to provision the SaveData @@ -60,12 +60,12 @@ ResultVal> ArchiveSource_SDSaveData::Open(u64 pr ResultCode ArchiveSource_SDSaveData::Format(u64 program_id, const FileSys::ArchiveFormatInfo& format_info) { std::string concrete_mount_point = GetSaveDataPath(mount_point, program_id); - FileUtil::DeleteDirRecursively(concrete_mount_point); - FileUtil::CreateFullPath(concrete_mount_point); + Common::FS::DeleteDirRecursively(concrete_mount_point); + Common::FS::CreateFullPath(concrete_mount_point); // Write the format metadata std::string metadata_path = GetSaveDataMetadataPath(mount_point, program_id); - FileUtil::IOFile file(metadata_path, "wb"); + Common::FS::IOFile file(metadata_path, "wb"); if (file.IsOpen()) { file.WriteBytes(&format_info, sizeof(format_info)); @@ -76,7 +76,7 @@ ResultCode ArchiveSource_SDSaveData::Format(u64 program_id, ResultVal ArchiveSource_SDSaveData::GetFormatInfo(u64 program_id) const { std::string metadata_path = GetSaveDataMetadataPath(mount_point, program_id); - FileUtil::IOFile file(metadata_path, "rb"); + Common::FS::IOFile file(metadata_path, "rb"); if (!file.IsOpen()) { LOG_ERROR(Service_FS, "Could not open metadata information for archive"); diff --git a/src/core/file_sys/archive_systemsavedata.cpp b/src/core/file_sys/archive_systemsavedata.cpp index ce82a64e5..5ac3a6f3f 100644 --- a/src/core/file_sys/archive_systemsavedata.cpp +++ b/src/core/file_sys/archive_systemsavedata.cpp @@ -58,7 +58,7 @@ ArchiveFactory_SystemSaveData::ArchiveFactory_SystemSaveData(const std::string& ResultVal> ArchiveFactory_SystemSaveData::Open(const Path& path, u64 program_id) { std::string fullpath = GetSystemSaveDataPath(base_path, path); - if (!FileUtil::Exists(fullpath)) { + if (!Common::FS::Exists(fullpath)) { // TODO(Subv): Check error code, this one is probably wrong return ERR_NOT_FORMATTED; } @@ -70,8 +70,8 @@ ResultCode ArchiveFactory_SystemSaveData::Format(const Path& path, const FileSys::ArchiveFormatInfo& format_info, u64 program_id) { std::string fullpath = GetSystemSaveDataPath(base_path, path); - FileUtil::DeleteDirRecursively(fullpath); - FileUtil::CreateFullPath(fullpath); + Common::FS::DeleteDirRecursively(fullpath); + Common::FS::CreateFullPath(fullpath); return RESULT_SUCCESS; } diff --git a/src/core/file_sys/cia_container.cpp b/src/core/file_sys/cia_container.cpp index 64ed8bbb0..86b67b643 100644 --- a/src/core/file_sys/cia_container.cpp +++ b/src/core/file_sys/cia_container.cpp @@ -66,7 +66,7 @@ Loader::ResultStatus CIAContainer::Load(const FileBackend& backend) { } Loader::ResultStatus CIAContainer::Load(const std::string& filepath) { - FileUtil::IOFile file(filepath, "rb"); + Common::FS::IOFile file(filepath, "rb"); if (!file.IsOpen()) return Loader::ResultStatus::Error; diff --git a/src/core/file_sys/disk_archive.cpp b/src/core/file_sys/disk_archive.cpp index cf1a3c567..4a1b291d9 100644 --- a/src/core/file_sys/disk_archive.cpp +++ b/src/core/file_sys/disk_archive.cpp @@ -58,7 +58,7 @@ bool DiskFile::Close() const { //////////////////////////////////////////////////////////////////////////////////////////////////// DiskDirectory::DiskDirectory(const std::string& path) { - directory.size = FileUtil::ScanDirectoryTree(path, directory); + directory.size = Common::FS::ScanDirectoryTree(path, directory); directory.isDirectory = true; children_iterator = directory.children.begin(); } @@ -67,7 +67,7 @@ u32 DiskDirectory::Read(const u32 count, Entry* entries) { u32 entries_read = 0; while (entries_read < count && children_iterator != directory.children.cend()) { - const FileUtil::FSTEntry& file = *children_iterator; + const Common::FS::FSTEntry& file = *children_iterator; const std::string& filename = file.virtualName; Entry& entry = entries[entries_read]; @@ -80,7 +80,7 @@ u32 DiskDirectory::Read(const u32 count, Entry* entries) { break; } - FileUtil::SplitFilename83(filename, entry.short_name, entry.extension); + Common::FS::SplitFilename83(filename, entry.short_name, entry.extension); entry.is_directory = file.isDirectory; entry.is_hidden = (filename[0] == '.'); diff --git a/src/core/file_sys/disk_archive.h b/src/core/file_sys/disk_archive.h index 2f0e5691a..e94410506 100644 --- a/src/core/file_sys/disk_archive.h +++ b/src/core/file_sys/disk_archive.h @@ -25,9 +25,9 @@ namespace FileSys { class DiskFile : public FileBackend { public: - DiskFile(FileUtil::IOFile&& file_, const Mode& mode_, + DiskFile(Common::FS::IOFile&& file_, const Mode& mode_, std::unique_ptr delay_generator_) - : file(new FileUtil::IOFile(std::move(file_))) { + : file(new Common::FS::IOFile(std::move(file_))) { delay_generator = std::move(delay_generator_); mode.hex = mode_.hex; } @@ -45,7 +45,7 @@ public: protected: Mode mode; - std::unique_ptr file; + std::unique_ptr file; private: DiskFile() = default; @@ -74,11 +74,11 @@ public: } protected: - FileUtil::FSTEntry directory{}; + Common::FS::FSTEntry directory{}; // We need to remember the last entry we returned, so a subsequent call to Read will continue // from the next one. This iterator will always point to the next unread entry. - std::vector::iterator children_iterator; + std::vector::iterator children_iterator; private: DiskDirectory() = default; diff --git a/src/core/file_sys/layered_fs.cpp b/src/core/file_sys/layered_fs.cpp index 31d85ee6b..cb6f6ca9e 100644 --- a/src/core/file_sys/layered_fs.cpp +++ b/src/core/file_sys/layered_fs.cpp @@ -140,17 +140,17 @@ std::string LayeredFS::ReadName(u32 offset, u32 name_length) { } void LayeredFS::LoadRelocations() { - if (!FileUtil::Exists(patch_path)) { + if (!Common::FS::Exists(patch_path)) { return; } - const FileUtil::DirectoryEntryCallable callback = [this, + const Common::FS::DirectoryEntryCallable callback = [this, &callback](u64* /*num_entries_out*/, const std::string& directory, const std::string& virtual_name) { auto* parent = directory_path_map.at(directory.substr(patch_path.size() - 1)); - if (FileUtil::IsDirectory(directory + virtual_name + DIR_SEP)) { + if (Common::FS::IsDirectory(directory + virtual_name + DIR_SEP)) { const auto path = (directory + virtual_name + DIR_SEP).substr(patch_path.size() - 1); if (!directory_path_map.count(path)) { // Add this directory auto directory = std::make_unique(); @@ -161,7 +161,7 @@ void LayeredFS::LoadRelocations() { parent->directories.emplace_back(std::move(directory)); LOG_INFO(Service_FS, "LayeredFS created directory {}", path); } - return FileUtil::ForeachDirectoryEntry(nullptr, directory + virtual_name + DIR_SEP, + return Common::FS::ForeachDirectoryEntry(nullptr, directory + virtual_name + DIR_SEP, callback); } @@ -179,16 +179,16 @@ void LayeredFS::LoadRelocations() { auto* file = file_path_map.at(path); file->relocation.type = 1; file->relocation.replace_file_path = directory + virtual_name; - file->relocation.size = FileUtil::GetSize(directory + virtual_name); + file->relocation.size = Common::FS::GetSize(directory + virtual_name); LOG_INFO(Service_FS, "LayeredFS replacement file in use for {}", path); return true; }; - FileUtil::ForeachDirectoryEntry(nullptr, patch_path, callback); + Common::FS::ForeachDirectoryEntry(nullptr, patch_path, callback); } void LayeredFS::LoadExtRelocations() { - if (!FileUtil::Exists(patch_ext_path)) { + if (!Common::FS::Exists(patch_ext_path)) { return; } @@ -197,11 +197,11 @@ void LayeredFS::LoadExtRelocations() { patch_ext_path.erase(patch_ext_path.size() - 1, 1); } - FileUtil::FSTEntry result; - FileUtil::ScanDirectoryTree(patch_ext_path, result, 256); + Common::FS::FSTEntry result; + Common::FS::ScanDirectoryTree(patch_ext_path, result, 256); for (const auto& entry : result.children) { - if (FileUtil::IsDirectory(entry.physicalName)) { + if (Common::FS::IsDirectory(entry.physicalName)) { continue; } @@ -230,7 +230,7 @@ void LayeredFS::LoadExtRelocations() { continue; } - FileUtil::IOFile patch_file(entry.physicalName, "rb"); + Common::FS::IOFile patch_file(entry.physicalName, "rb"); if (!patch_file) { LOG_ERROR(Service_FS, "LayeredFS Could not open file {}", entry.physicalName); continue; @@ -522,7 +522,7 @@ std::size_t LayeredFS::ReadFile(std::size_t offset, std::size_t length, u8* buff romfs->ReadFile(relocation.original_offset + relative_offset, to_read, buffer + read_size); } else if (relocation.type == 1) { // replace - FileUtil::IOFile replace_file(relocation.replace_file_path, "rb"); + Common::FS::IOFile replace_file(relocation.replace_file_path, "rb"); if (replace_file) { replace_file.Seek(relative_offset, SEEK_SET); replace_file.ReadBytes(buffer + read_size, to_read); @@ -548,7 +548,7 @@ std::size_t LayeredFS::ReadFile(std::size_t offset, std::size_t length, u8* buff } bool LayeredFS::ExtractDirectory(Directory& current, const std::string& target_path) { - if (!FileUtil::CreateFullPath(target_path + current.path)) { + if (!Common::FS::CreateFullPath(target_path + current.path)) { LOG_ERROR(Service_FS, "Could not create path {}", target_path + current.path); return false; } @@ -560,7 +560,7 @@ bool LayeredFS::ExtractDirectory(Directory& current, const std::string& target_p const auto path = target_path + file->path; LOG_INFO(Service_FS, "Extracting {} to {}", file->path, path); - FileUtil::IOFile target_file(path, "wb"); + Common::FS::IOFile target_file(path, "wb"); if (!target_file) { LOG_ERROR(Service_FS, "Could not open file {}", path); return false; diff --git a/src/core/file_sys/ncch_container.cpp b/src/core/file_sys/ncch_container.cpp index 540f16e78..0480aacf3 100644 --- a/src/core/file_sys/ncch_container.cpp +++ b/src/core/file_sys/ncch_container.cpp @@ -116,7 +116,7 @@ static bool LZSS_Decompress(const u8* compressed, u32 compressed_size, u8* decom NCCHContainer::NCCHContainer(const std::string& filepath, u32 ncch_offset, u32 partition) : ncch_offset(ncch_offset), partition(partition), filepath(filepath) { - file = FileUtil::IOFile(filepath, "rb"); + file = Common::FS::IOFile(filepath, "rb"); } Loader::ResultStatus NCCHContainer::OpenFile(const std::string& filepath, u32 ncch_offset, @@ -124,7 +124,7 @@ Loader::ResultStatus NCCHContainer::OpenFile(const std::string& filepath, u32 nc this->filepath = filepath; this->ncch_offset = ncch_offset; this->partition = partition; - file = FileUtil::IOFile(filepath, "rb"); + file = Common::FS::IOFile(filepath, "rb"); if (!file.IsOpen()) { LOG_WARNING(Service_FS, "Failed to open {}", filepath); @@ -330,7 +330,7 @@ Loader::ResultStatus NCCHContainer::Load() { // System archives and DLC don't have an extended header but have RomFS if (ncch_header.extended_header_size) { - auto read_exheader = [this](FileUtil::IOFile& file) { + auto read_exheader = [this](Common::FS::IOFile& file) { const std::size_t size = sizeof(exheader_header); return file && file.ReadBytes(&exheader_header, size) == size; }; @@ -360,7 +360,7 @@ Loader::ResultStatus NCCHContainer::Load() { } const auto mods_path = - fmt::format("{}mods/{:016X}/", FileUtil::GetUserPath(FileUtil::UserPath::LoadDir), + fmt::format("{}mods/{:016X}/", Common::FS::GetUserPath(Common::FS::UserPath::LoadDir), GetModId(ncch_header.program_id)); const std::array exheader_override_paths{{ mods_path + "exheader.bin", @@ -369,7 +369,7 @@ Loader::ResultStatus NCCHContainer::Load() { bool has_exheader_override = false; for (const auto& path : exheader_override_paths) { - FileUtil::IOFile exheader_override_file{path, "rb"}; + Common::FS::IOFile exheader_override_file{path, "rb"}; if (read_exheader(exheader_override_file)) { has_exheader_override = true; break; @@ -430,7 +430,7 @@ Loader::ResultStatus NCCHContainer::Load() { .ProcessData(data, data, sizeof(exefs_header)); } - exefs_file = FileUtil::IOFile(filepath, "rb"); + exefs_file = Common::FS::IOFile(filepath, "rb"); has_exefs = true; } @@ -451,15 +451,15 @@ Loader::ResultStatus NCCHContainer::Load() { Loader::ResultStatus NCCHContainer::LoadOverrides() { // Check for split-off files, mark the archive as tainted if we will use them std::string romfs_override = filepath + ".romfs"; - if (FileUtil::Exists(romfs_override)) { + if (Common::FS::Exists(romfs_override)) { is_tainted = true; } // If we have a split-off exefs file/folder, it takes priority std::string exefs_override = filepath + ".exefs"; std::string exefsdir_override = filepath + ".exefsdir/"; - if (FileUtil::Exists(exefs_override)) { - exefs_file = FileUtil::IOFile(exefs_override, "rb"); + if (Common::FS::Exists(exefs_override)) { + exefs_file = Common::FS::IOFile(exefs_override, "rb"); if (exefs_file.ReadBytes(&exefs_header, sizeof(ExeFs_Header)) == sizeof(ExeFs_Header)) { LOG_DEBUG(Service_FS, "Loading ExeFS section from {}", exefs_override); @@ -467,9 +467,9 @@ Loader::ResultStatus NCCHContainer::LoadOverrides() { is_tainted = true; has_exefs = true; } else { - exefs_file = FileUtil::IOFile(filepath, "rb"); + exefs_file = Common::FS::IOFile(filepath, "rb"); } - } else if (FileUtil::Exists(exefsdir_override) && FileUtil::IsDirectory(exefsdir_override)) { + } else if (Common::FS::Exists(exefsdir_override) && Common::FS::IsDirectory(exefsdir_override)) { is_tainted = true; } @@ -585,7 +585,7 @@ Loader::ResultStatus NCCHContainer::ApplyCodePatch(std::vector& code) const }; const auto mods_path = - fmt::format("{}mods/{:016X}/", FileUtil::GetUserPath(FileUtil::UserPath::LoadDir), + fmt::format("{}mods/{:016X}/", Common::FS::GetUserPath(Common::FS::UserPath::LoadDir), GetModId(ncch_header.program_id)); const std::array patch_paths{{ {mods_path + "exefs/code.ips", Patch::ApplyIpsPatch}, @@ -597,7 +597,7 @@ Loader::ResultStatus NCCHContainer::ApplyCodePatch(std::vector& code) const }}; for (const PatchLocation& info : patch_paths) { - FileUtil::IOFile file{info.path, "rb"}; + Common::FS::IOFile file{info.path, "rb"}; if (!file) continue; @@ -631,7 +631,7 @@ Loader::ResultStatus NCCHContainer::LoadOverrideExeFSSection(const char* name, return Loader::ResultStatus::Error; const auto mods_path = - fmt::format("{}mods/{:016X}/", FileUtil::GetUserPath(FileUtil::UserPath::LoadDir), + fmt::format("{}mods/{:016X}/", Common::FS::GetUserPath(Common::FS::UserPath::LoadDir), GetModId(ncch_header.program_id)); const std::array override_paths{{ mods_path + "exefs/" + override_name, @@ -640,7 +640,7 @@ Loader::ResultStatus NCCHContainer::LoadOverrideExeFSSection(const char* name, }}; for (const auto& path : override_paths) { - FileUtil::IOFile section_file(path, "rb"); + Common::FS::IOFile section_file(path, "rb"); if (section_file.IsOpen()) { auto section_size = section_file.GetSize(); @@ -683,7 +683,7 @@ Loader::ResultStatus NCCHContainer::ReadRomFS(std::shared_ptr& romf return Loader::ResultStatus::Error; // We reopen the file, to allow its position to be independent from file's - FileUtil::IOFile romfs_file_inner(filepath, "rb"); + Common::FS::IOFile romfs_file_inner(filepath, "rb"); if (!romfs_file_inner.IsOpen()) return Loader::ResultStatus::Error; @@ -698,10 +698,10 @@ Loader::ResultStatus NCCHContainer::ReadRomFS(std::shared_ptr& romf } const auto path = - fmt::format("{}mods/{:016X}/", FileUtil::GetUserPath(FileUtil::UserPath::LoadDir), + fmt::format("{}mods/{:016X}/", Common::FS::GetUserPath(Common::FS::UserPath::LoadDir), GetModId(ncch_header.program_id)); if (use_layered_fs && - (FileUtil::Exists(path + "romfs/") || FileUtil::Exists(path + "romfs_ext/"))) { + (Common::FS::Exists(path + "romfs/") || Common::FS::Exists(path + "romfs_ext/"))) { romfs_file = std::make_shared(std::move(direct_romfs), path + "romfs/", path + "romfs_ext/"); @@ -730,8 +730,8 @@ Loader::ResultStatus NCCHContainer::DumpRomFS(const std::string& target_path) { Loader::ResultStatus NCCHContainer::ReadOverrideRomFS(std::shared_ptr& romfs_file) { // Check for RomFS overrides std::string split_filepath = filepath + ".romfs"; - if (FileUtil::Exists(split_filepath)) { - FileUtil::IOFile romfs_file_inner(split_filepath, "rb"); + if (Common::FS::Exists(split_filepath)) { + Common::FS::IOFile romfs_file_inner(split_filepath, "rb"); if (romfs_file_inner.IsOpen()) { LOG_WARNING(Service_FS, "File {} overriding built-in RomFS; LayeredFS not enabled", split_filepath); diff --git a/src/core/file_sys/ncch_container.h b/src/core/file_sys/ncch_container.h index 9db1d90be..54e7835da 100644 --- a/src/core/file_sys/ncch_container.h +++ b/src/core/file_sys/ncch_container.h @@ -368,8 +368,8 @@ private: u32 partition = 0; std::string filepath; - FileUtil::IOFile file; - FileUtil::IOFile exefs_file; + Common::FS::IOFile file; + Common::FS::IOFile exefs_file; }; } // namespace FileSys diff --git a/src/core/file_sys/path_parser.cpp b/src/core/file_sys/path_parser.cpp index 2daadfbb7..cae752778 100644 --- a/src/core/file_sys/path_parser.cpp +++ b/src/core/file_sys/path_parser.cpp @@ -59,7 +59,7 @@ PathParser::PathParser(const Path& path) { PathParser::HostStatus PathParser::GetHostStatus(std::string_view mount_point) const { std::string path{mount_point}; - if (!FileUtil::IsDirectory(path)) + if (!Common::FS::IsDirectory(path)) return InvalidMountPoint; if (path_sequence.empty()) { return DirectoryFound; @@ -70,17 +70,17 @@ PathParser::HostStatus PathParser::GetHostStatus(std::string_view mount_point) c path += '/'; path += *iter; - if (!FileUtil::Exists(path)) + if (!Common::FS::Exists(path)) return PathNotFound; - if (FileUtil::IsDirectory(path)) + if (Common::FS::IsDirectory(path)) continue; return FileInPath; } path += "/" + path_sequence.back(); - if (!FileUtil::Exists(path)) + if (!Common::FS::Exists(path)) return NotFound; - if (FileUtil::IsDirectory(path)) + if (Common::FS::IsDirectory(path)) return DirectoryFound; return FileFound; } diff --git a/src/core/file_sys/romfs_reader.h b/src/core/file_sys/romfs_reader.h index 26dcb9857..35b58138c 100644 --- a/src/core/file_sys/romfs_reader.h +++ b/src/core/file_sys/romfs_reader.h @@ -30,11 +30,11 @@ private: */ class DirectRomFSReader : public RomFSReader { public: - DirectRomFSReader(FileUtil::IOFile&& file, std::size_t file_offset, std::size_t data_size) + DirectRomFSReader(Common::FS::IOFile&& file, std::size_t file_offset, std::size_t data_size) : is_encrypted(false), file(std::move(file)), file_offset(file_offset), data_size(data_size) {} - DirectRomFSReader(FileUtil::IOFile&& file, std::size_t file_offset, std::size_t data_size, + DirectRomFSReader(Common::FS::IOFile&& file, std::size_t file_offset, std::size_t data_size, const std::array& key, const std::array& ctr, std::size_t crypto_offset) : is_encrypted(true), file(std::move(file)), key(key), ctr(ctr), file_offset(file_offset), @@ -50,7 +50,7 @@ public: private: bool is_encrypted; - FileUtil::IOFile file; + Common::FS::IOFile file; std::array key; std::array ctr; u64 file_offset; diff --git a/src/core/file_sys/savedata_archive.cpp b/src/core/file_sys/savedata_archive.cpp index 28124eb24..cd72358da 100644 --- a/src/core/file_sys/savedata_archive.cpp +++ b/src/core/file_sys/savedata_archive.cpp @@ -79,14 +79,14 @@ ResultVal> SaveDataArchive::OpenFile(const Path& pa return ERROR_FILE_NOT_FOUND; } else { // Create the file - FileUtil::CreateEmptyFile(full_path); + Common::FS::CreateEmptyFile(full_path); } break; case PathParser::FileFound: break; // Expected 'success' case } - FileUtil::IOFile file(full_path, mode.write_flag ? "r+b" : "rb"); + Common::FS::IOFile file(full_path, mode.write_flag ? "r+b" : "rb"); if (!file.IsOpen()) { LOG_CRITICAL(Service_FS, "(unreachable) Unknown error opening {}", full_path); return ERROR_FILE_NOT_FOUND; @@ -123,7 +123,7 @@ ResultCode SaveDataArchive::DeleteFile(const Path& path) const { break; // Expected 'success' case } - if (FileUtil::Delete(full_path)) { + if (Common::FS::Delete(full_path)) { return RESULT_SUCCESS; } @@ -150,7 +150,7 @@ ResultCode SaveDataArchive::RenameFile(const Path& src_path, const Path& dest_pa const auto src_path_full = path_parser_src.BuildHostPath(mount_point); const auto dest_path_full = path_parser_dest.BuildHostPath(mount_point); - if (FileUtil::Rename(src_path_full, dest_path_full)) { + if (Common::FS::Rename(src_path_full, dest_path_full)) { return RESULT_SUCCESS; } @@ -200,12 +200,12 @@ static ResultCode DeleteDirectoryHelper(const Path& path, const std::string& mou } ResultCode SaveDataArchive::DeleteDirectory(const Path& path) const { - return DeleteDirectoryHelper(path, mount_point, FileUtil::DeleteDir); + return DeleteDirectoryHelper(path, mount_point, Common::FS::DeleteDir); } ResultCode SaveDataArchive::DeleteDirectoryRecursively(const Path& path) const { return DeleteDirectoryHelper( - path, mount_point, [](const std::string& p) { return FileUtil::DeleteDirRecursively(p); }); + path, mount_point, [](const std::string& p) { return Common::FS::DeleteDirRecursively(p); }); } ResultCode SaveDataArchive::CreateFile(const FileSys::Path& path, u64 size) const { @@ -237,11 +237,11 @@ ResultCode SaveDataArchive::CreateFile(const FileSys::Path& path, u64 size) cons } if (size == 0) { - FileUtil::CreateEmptyFile(full_path); + Common::FS::CreateEmptyFile(full_path); return RESULT_SUCCESS; } - FileUtil::IOFile file(full_path, "wb"); + Common::FS::IOFile file(full_path, "wb"); // Creates a sparse file (or a normal file on filesystems without the concept of sparse files) // We do this by seeking to the right size, then writing a single null byte. if (file.Seek(size - 1, SEEK_SET) && file.WriteBytes("", 1) == 1) { @@ -281,7 +281,7 @@ ResultCode SaveDataArchive::CreateDirectory(const Path& path) const { break; // Expected 'success' case } - if (FileUtil::CreateDir(mount_point + path.AsString())) { + if (Common::FS::CreateDir(mount_point + path.AsString())) { return RESULT_SUCCESS; } @@ -309,7 +309,7 @@ ResultCode SaveDataArchive::RenameDirectory(const Path& src_path, const Path& de const auto src_path_full = path_parser_src.BuildHostPath(mount_point); const auto dest_path_full = path_parser_dest.BuildHostPath(mount_point); - if (FileUtil::Rename(src_path_full, dest_path_full)) { + if (Common::FS::Rename(src_path_full, dest_path_full)) { return RESULT_SUCCESS; } diff --git a/src/core/file_sys/seed_db.cpp b/src/core/file_sys/seed_db.cpp index 1e29a203b..8ea821cf7 100644 --- a/src/core/file_sys/seed_db.cpp +++ b/src/core/file_sys/seed_db.cpp @@ -12,9 +12,9 @@ namespace FileSys { bool SeedDB::Load() { seeds.clear(); const std::string path{ - fmt::format("{}/seeddb.bin", FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir))}; - if (!FileUtil::Exists(path)) { - if (!FileUtil::CreateFullPath(path)) { + fmt::format("{}/seeddb.bin", Common::FS::GetUserPath(Common::FS::UserPath::SysDataDir))}; + if (!Common::FS::Exists(path)) { + if (!Common::FS::CreateFullPath(path)) { LOG_ERROR(Service_FS, "Failed to create seed database"); return false; } @@ -24,7 +24,7 @@ bool SeedDB::Load() { } return true; } - FileUtil::IOFile file{path, "rb"}; + Common::FS::IOFile file{path, "rb"}; if (!file.IsOpen()) { LOG_ERROR(Service_FS, "Failed to open seed database"); return false; @@ -59,12 +59,12 @@ bool SeedDB::Load() { bool SeedDB::Save() { const std::string path{ - fmt::format("{}/seeddb.bin", FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir))}; - if (!FileUtil::CreateFullPath(path)) { + fmt::format("{}/seeddb.bin", Common::FS::GetUserPath(Common::FS::UserPath::SysDataDir))}; + if (!Common::FS::CreateFullPath(path)) { LOG_ERROR(Service_FS, "Failed to create seed database"); return false; } - FileUtil::IOFile file{path, "wb"}; + Common::FS::IOFile file{path, "wb"}; if (!file.IsOpen()) { LOG_ERROR(Service_FS, "Failed to open seed database"); return false; diff --git a/src/core/file_sys/title_metadata.cpp b/src/core/file_sys/title_metadata.cpp index e25d2d238..2735eea2d 100644 --- a/src/core/file_sys/title_metadata.cpp +++ b/src/core/file_sys/title_metadata.cpp @@ -17,7 +17,7 @@ namespace FileSys { Loader::ResultStatus TitleMetadata::Load(const std::string& file_path) { - FileUtil::IOFile file(file_path, "rb"); + Common::FS::IOFile file(file_path, "rb"); if (!file.IsOpen()) return Loader::ResultStatus::Error; @@ -78,7 +78,7 @@ Loader::ResultStatus TitleMetadata::Load(const std::vector& file_data, std:: } Loader::ResultStatus TitleMetadata::Save(const std::string& file_path) { - FileUtil::IOFile file(file_path, "wb"); + Common::FS::IOFile file(file_path, "wb"); if (!file.IsOpen()) return Loader::ResultStatus::Error; diff --git a/src/core/frontend/applets/mii_selector.cpp b/src/core/frontend/applets/mii_selector.cpp index 2fdfe3049..cbccf841c 100644 --- a/src/core/frontend/applets/mii_selector.cpp +++ b/src/core/frontend/applets/mii_selector.cpp @@ -18,7 +18,7 @@ void MiiSelector::Finalize(u32 return_code, HLE::Applets::MiiData mii) { std::vector LoadMiis() { std::vector miis; - std::string nand_directory{FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)}; + std::string nand_directory{Common::FS::GetUserPath(Common::FS::UserPath::NANDDir)}; FileSys::ArchiveFactory_ExtSaveData extdata_archive_factory(nand_directory, true); auto archive_result = extdata_archive_factory.Open(Service::PTM::ptm_shared_extdata_id, 0); diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index f215d67ce..d817a62e1 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -107,7 +107,7 @@ ResultCode CIAFile::WriteTitleMetadata() { // If a TMD already exists for this app (ie 00000000.tmd), the incoming TMD // will be the same plus one, (ie 00000001.tmd), both will be kept until // the install is finalized and old contents can be discarded. - if (FileUtil::Exists(GetTitleMetadataPath(media_type, tmd.GetTitleID()))) + if (Common::FS::Exists(GetTitleMetadataPath(media_type, tmd.GetTitleID()))) is_update = true; std::string tmd_path = GetTitleMetadataPath(media_type, tmd.GetTitleID(), is_update); @@ -115,7 +115,7 @@ ResultCode CIAFile::WriteTitleMetadata() { // Create content/ folder if it doesn't exist std::string tmd_folder; Common::SplitPath(tmd_path, &tmd_folder, nullptr, nullptr); - FileUtil::CreateFullPath(tmd_folder); + Common::FS::CreateFullPath(tmd_folder); // Save TMD so that we can start getting new .app paths if (tmd.Save(tmd_path) != Loader::ResultStatus::Success) @@ -126,7 +126,7 @@ ResultCode CIAFile::WriteTitleMetadata() { Common::SplitPath(GetTitleContentPath(media_type, tmd.GetTitleID(), FileSys::TMDContentIndex::Main, is_update), &app_folder, nullptr, nullptr); - FileUtil::CreateFullPath(app_folder); + Common::FS::CreateFullPath(app_folder); auto content_count = container.GetTitleMetadata().GetContentCount(); content_written.resize(content_count); @@ -169,7 +169,7 @@ ResultVal CIAFile::WriteContentData(u64 offset, std::size_t length, // Since the incoming TMD has already been written, we can use GetTitleContentPath // to get the content paths to write to. FileSys::TitleMetadata tmd = container.GetTitleMetadata(); - FileUtil::IOFile file(GetTitleContentPath(media_type, tmd.GetTitleID(), i, is_update), + Common::FS::IOFile file(GetTitleContentPath(media_type, tmd.GetTitleID(), i, is_update), content_written[i] ? "ab" : "wb"); if (!file.IsOpen()) { @@ -285,7 +285,7 @@ bool CIAFile::Close() const { // Install aborted if (!complete) { LOG_ERROR(Service_AM, "CIAFile closed prematurely, aborting install..."); - FileUtil::DeleteDir(GetTitlePath(media_type, container.GetTitleMetadata().GetTitleID())); + Common::FS::DeleteDir(GetTitlePath(media_type, container.GetTitleMetadata().GetTitleID())); return true; } @@ -294,7 +294,7 @@ bool CIAFile::Close() const { GetTitleMetadataPath(media_type, container.GetTitleMetadata().GetTitleID(), false); std::string new_tmd_path = GetTitleMetadataPath(media_type, container.GetTitleMetadata().GetTitleID(), true); - if (FileUtil::Exists(new_tmd_path) && old_tmd_path != new_tmd_path) { + if (Common::FS::Exists(new_tmd_path) && old_tmd_path != new_tmd_path) { FileSys::TitleMetadata old_tmd; FileSys::TitleMetadata new_tmd; @@ -315,10 +315,10 @@ bool CIAFile::Close() const { if (abort) break; - FileUtil::Delete(GetTitleContentPath(media_type, old_tmd.GetTitleID(), old_index)); + Common::FS::Delete(GetTitleContentPath(media_type, old_tmd.GetTitleID(), old_index)); } - FileUtil::Delete(old_tmd_path); + Common::FS::Delete(old_tmd_path); } return true; } @@ -329,7 +329,7 @@ InstallStatus InstallCIA(const std::string& path, std::function&& update_callback) { LOG_INFO(Service_AM, "Installing {}...", path); - if (!FileUtil::Exists(path)) { + if (!Common::FS::Exists(path)) { LOG_ERROR(Service_AM, "File {} does not exist!", path); return InstallStatus::ErrorFileNotFound; } @@ -350,7 +350,7 @@ InstallStatus InstallCIA(const std::string& path, } } - FileUtil::IOFile file(path, "rb"); + Common::FS::IOFile file(path, "rb"); if (!file.IsOpen()) return InstallStatus::ErrorFailedToOpenFile; @@ -374,11 +374,11 @@ InstallStatus InstallCIA(const std::string& path, LOG_INFO(Service_AM, "Installed {} successfully.", path); - const FileUtil::DirectoryEntryCallable callback = + const Common::FS::DirectoryEntryCallable callback = [&callback](u64* num_entries_out, const std::string& directory, const std::string& virtual_name) -> bool { const std::string physical_name = directory + DIR_SEP + virtual_name; - const bool is_dir = FileUtil::IsDirectory(physical_name); + const bool is_dir = Common::FS::IsDirectory(physical_name); if (!is_dir) { std::unique_ptr loader = Loader::GetLoader(physical_name); if (!loader) { @@ -392,10 +392,10 @@ InstallStatus InstallCIA(const std::string& path, } return true; } else { - return FileUtil::ForeachDirectoryEntry(nullptr, physical_name, callback); + return Common::FS::ForeachDirectoryEntry(nullptr, physical_name, callback); } }; - if (!FileUtil::ForeachDirectoryEntry( + if (!Common::FS::ForeachDirectoryEntry( nullptr, GetTitlePath( Service::AM::GetTitleMediaType(container.GetTitleMetadata().GetTitleID()), @@ -439,9 +439,9 @@ std::string GetTitleMetadataPath(Service::FS::MediaType media_type, u64 tid, boo constexpr u32 MAX_TMD_ID = 0xFFFFFFFF; u32 base_id = MAX_TMD_ID; u32 update_id = 0; - FileUtil::FSTEntry entries; - FileUtil::ScanDirectoryTree(content_path, entries); - for (const FileUtil::FSTEntry& entry : entries.children) { + Common::FS::FSTEntry entries; + Common::FS::ScanDirectoryTree(content_path, entries); + for (const Common::FS::FSTEntry& entry : entries.children) { std::string filename_filename, filename_extension; Common::SplitPath(entry.virtualName, nullptr, &filename_filename, &filename_extension); @@ -522,12 +522,12 @@ std::string GetTitlePath(Service::FS::MediaType media_type, u64 tid) { std::string GetMediaTitlePath(Service::FS::MediaType media_type) { if (media_type == Service::FS::MediaType::NAND) - return fmt::format("{}{}/title/", FileUtil::GetUserPath(FileUtil::UserPath::NANDDir), + return fmt::format("{}{}/title/", Common::FS::GetUserPath(Common::FS::UserPath::NANDDir), SYSTEM_ID); if (media_type == Service::FS::MediaType::SDMC) return fmt::format("{}Nintendo 3DS/{}/{}/title/", - FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir), SYSTEM_ID, + Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir), SYSTEM_ID, SDCARD_ID); if (media_type == Service::FS::MediaType::GameCard) { @@ -546,10 +546,10 @@ void Module::ScanForTitles(Service::FS::MediaType media_type) { std::string title_path = GetMediaTitlePath(media_type); - FileUtil::FSTEntry entries; - FileUtil::ScanDirectoryTree(title_path, entries, 1); - for (const FileUtil::FSTEntry& tid_high : entries.children) { - for (const FileUtil::FSTEntry& tid_low : tid_high.children) { + Common::FS::FSTEntry entries; + Common::FS::ScanDirectoryTree(title_path, entries, 1); + for (const Common::FS::FSTEntry& tid_high : entries.children) { + for (const Common::FS::FSTEntry& tid_low : tid_high.children) { std::string tid_string = tid_high.virtualName + tid_low.virtualName; if (tid_string.length() == TITLE_ID_VALID_LENGTH) { @@ -632,7 +632,7 @@ void Module::Interface::FindDLCContentInfos(Kernel::HLERequestContext& ctx) { content_info.ownership = OWNERSHIP_OWNED; // TODO(Steveice10): Pull this from the ticket. - if (FileUtil::Exists(GetTitleContentPath(media_type, title_id, content_requested[i]))) { + if (Common::FS::Exists(GetTitleContentPath(media_type, title_id, content_requested[i]))) { content_info.ownership |= OWNERSHIP_DOWNLOADED; } @@ -684,7 +684,7 @@ void Module::Interface::ListDLCContentInfos(Kernel::HLERequestContext& ctx) { content_info.ownership = OWNERSHIP_OWNED; // TODO(Steveice10): Pull this from the ticket. - if (FileUtil::Exists(GetTitleContentPath(media_type, title_id, i))) { + if (Common::FS::Exists(GetTitleContentPath(media_type, title_id, i))) { content_info.ownership |= OWNERSHIP_DOWNLOADED; } @@ -802,17 +802,17 @@ void Module::Interface::DeleteUserProgram(Kernel::HLERequestContext& ctx) { } LOG_INFO(Service_AM, "Deleting title 0x{:016x}", title_id); std::string path = GetTitlePath(media_type, title_id); - if (!FileUtil::Exists(path)) { + if (!Common::FS::Exists(path)) { rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState, ErrorLevel::Permanent)); LOG_ERROR(Service_AM, "Title not found"); return; } - bool success = FileUtil::DeleteDirRecursively(path); + bool success = Common::FS::DeleteDirRecursively(path); am->ScanForAllTitles(); rb.Push(RESULT_SUCCESS); if (!success) - LOG_ERROR(Service_AM, "FileUtil::DeleteDirRecursively unexpectedly failed"); + LOG_ERROR(Service_AM, "Common::FS::DeleteDirRecursively unexpectedly failed"); } void Module::Interface::GetProductCode(Kernel::HLERequestContext& ctx) { @@ -821,7 +821,7 @@ void Module::Interface::GetProductCode(Kernel::HLERequestContext& ctx) { u64 title_id = rp.Pop(); std::string path = GetTitleContentPath(media_type, title_id); - if (!FileUtil::Exists(path)) { + if (!Common::FS::Exists(path)) { IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState, ErrorLevel::Permanent)); @@ -1016,7 +1016,7 @@ void Module::Interface::CheckContentRights(Kernel::HLERequestContext& ctx) { // TODO(shinyquagsire23): Read tickets for this instead? bool has_rights = - FileUtil::Exists(GetTitleContentPath(Service::FS::MediaType::SDMC, tid, content_index)); + Common::FS::Exists(GetTitleContentPath(Service::FS::MediaType::SDMC, tid, content_index)); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); rb.Push(RESULT_SUCCESS); // No error @@ -1032,7 +1032,7 @@ void Module::Interface::CheckContentRightsIgnorePlatform(Kernel::HLERequestConte // TODO(shinyquagsire23): Read tickets for this instead? bool has_rights = - FileUtil::Exists(GetTitleContentPath(Service::FS::MediaType::SDMC, tid, content_index)); + Common::FS::Exists(GetTitleContentPath(Service::FS::MediaType::SDMC, tid, content_index)); IPC::RequestBuilder rb = rp.MakeBuilder(2, 0); rb.Push(RESULT_SUCCESS); // No error @@ -1396,17 +1396,17 @@ void Module::Interface::DeleteProgram(Kernel::HLERequestContext& ctx) { LOG_INFO(Service_AM, "Deleting title 0x{:016x}", title_id); std::string path = GetTitlePath(media_type, title_id); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); - if (!FileUtil::Exists(path)) { + if (!Common::FS::Exists(path)) { rb.Push(ResultCode(ErrorDescription::NotFound, ErrorModule::AM, ErrorSummary::InvalidState, ErrorLevel::Permanent)); LOG_ERROR(Service_AM, "Title not found"); return; } - bool success = FileUtil::DeleteDirRecursively(path); + bool success = Common::FS::DeleteDirRecursively(path); am->ScanForAllTitles(); rb.Push(RESULT_SUCCESS); if (!success) - LOG_ERROR(Service_AM, "FileUtil::DeleteDirRecursively unexpectedly failed"); + LOG_ERROR(Service_AM, "Common::FS::DeleteDirRecursively unexpectedly failed"); } void Module::Interface::GetSystemUpdaterMutex(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index bb39074a2..83d397d3f 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -213,10 +213,10 @@ bool Module::LoadLegacySharedFont() { // generated by the APT:U service. The best way to get is by dumping it from RAM. We've provided // a homebrew app to do this: https://github.com/citra-emu/3dsutils. Put the resulting file // "shared_font.bin" in the Citra "sysdata" directory. - std::string filepath = FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir) + SHARED_FONT; + std::string filepath = Common::FS::GetUserPath(Common::FS::UserPath::SysDataDir) + SHARED_FONT; - FileUtil::CreateFullPath(filepath); // Create path if not already created - FileUtil::IOFile file(filepath, "rb"); + Common::FS::CreateFullPath(filepath); // Create path if not already created + Common::FS::IOFile file(filepath, "rb"); if (file.IsOpen()) { file.ReadBytes(shared_font_mem->GetPointer(), file.GetSize()); return true; diff --git a/src/core/hle/service/cecd/cecd.cpp b/src/core/hle/service/cecd/cecd.cpp index 3593a167c..e0884298d 100644 --- a/src/core/hle/service/cecd/cecd.cpp +++ b/src/core/hle/service/cecd/cecd.cpp @@ -1380,7 +1380,7 @@ Module::Module(Core::System& system) : system(system) { change_state_event = system.Kernel().CreateEvent(Kernel::ResetType::OneShot, "CECD::change_state_event"); - const std::string& nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); + const std::string& nand_directory = Common::FS::GetUserPath(Common::FS::UserPath::NANDDir); FileSys::ArchiveFactory_SystemSaveData systemsavedata_factory(nand_directory); // Open the SystemSaveData archive 0x00010026 diff --git a/src/core/hle/service/cfg/cfg.cpp b/src/core/hle/service/cfg/cfg.cpp index 7f8c16e03..209927fdd 100644 --- a/src/core/hle/service/cfg/cfg.cpp +++ b/src/core/hle/service/cfg/cfg.cpp @@ -560,7 +560,7 @@ ResultCode Module::FormatConfig() { } // namespace Service::CFG ResultCode Module::LoadConfigNANDSaveFile() { - const std::string& nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); + const std::string& nand_directory = Common::FS::GetUserPath(Common::FS::UserPath::NANDDir); FileSys::ArchiveFactory_SystemSaveData systemsavedata_factory(nand_directory); // Open the SystemSaveData archive 0x00010017 diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index e36fec4de..648f27944 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp @@ -32,10 +32,10 @@ namespace Service::FS { MediaType GetMediaTypeFromPath(std::string_view path) { - if (path.rfind(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir), 0) == 0) { + if (path.rfind(Common::FS::GetUserPath(Common::FS::UserPath::NANDDir), 0) == 0) { return MediaType::NAND; } - if (path.rfind(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir), 0) == 0) { + if (path.rfind(Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir), 0) == 0) { return MediaType::SDMC; } return MediaType::GameCard; @@ -263,9 +263,9 @@ ResultCode ArchiveManager::DeleteExtSaveData(MediaType media_type, u32 high, u32 std::string media_type_directory; if (media_type == MediaType::NAND) { - media_type_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); + media_type_directory = Common::FS::GetUserPath(Common::FS::UserPath::NANDDir); } else if (media_type == MediaType::SDMC) { - media_type_directory = FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir); + media_type_directory = Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir); } else { LOG_ERROR(Service_FS, "Unsupported media type {}", media_type); return ResultCode(-1); // TODO(Subv): Find the right error code @@ -275,7 +275,7 @@ ResultCode ArchiveManager::DeleteExtSaveData(MediaType media_type, u32 high, u32 std::string base_path = FileSys::GetExtDataContainerPath(media_type_directory, media_type == MediaType::NAND); std::string extsavedata_path = FileSys::GetExtSaveDataPath(base_path, path); - if (FileUtil::Exists(extsavedata_path) && !FileUtil::DeleteDirRecursively(extsavedata_path)) + if (Common::FS::Exists(extsavedata_path) && !Common::FS::DeleteDirRecursively(extsavedata_path)) return ResultCode(-1); // TODO(Subv): Find the right error code return RESULT_SUCCESS; } @@ -284,10 +284,10 @@ ResultCode ArchiveManager::DeleteSystemSaveData(u32 high, u32 low) { // Construct the binary path to the archive first const FileSys::Path path = FileSys::ConstructSystemSaveDataBinaryPath(high, low); - const std::string& nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); + const std::string& nand_directory = Common::FS::GetUserPath(Common::FS::UserPath::NANDDir); const std::string base_path = FileSys::GetSystemSaveDataContainerPath(nand_directory); const std::string systemsavedata_path = FileSys::GetSystemSaveDataPath(base_path, path); - if (!FileUtil::DeleteDirRecursively(systemsavedata_path)) { + if (!Common::FS::DeleteDirRecursively(systemsavedata_path)) { return ResultCode(-1); // TODO(Subv): Find the right error code } @@ -298,10 +298,10 @@ ResultCode ArchiveManager::CreateSystemSaveData(u32 high, u32 low) { // Construct the binary path to the archive first const FileSys::Path path = FileSys::ConstructSystemSaveDataBinaryPath(high, low); - const std::string& nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); + const std::string& nand_directory = Common::FS::GetUserPath(Common::FS::UserPath::NANDDir); const std::string base_path = FileSys::GetSystemSaveDataContainerPath(nand_directory); const std::string systemsavedata_path = FileSys::GetSystemSaveDataPath(base_path, path); - if (!FileUtil::CreateFullPath(systemsavedata_path)) { + if (!Common::FS::CreateFullPath(systemsavedata_path)) { return ResultCode(-1); // TODO(Subv): Find the right error code } @@ -322,8 +322,8 @@ void ArchiveManager::RegisterArchiveTypes() { // TODO(Subv): Add the other archive types (see here for the known types: // http://3dbrew.org/wiki/FS:OpenArchive#Archive_idcodes). - std::string sdmc_directory = FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir); - std::string nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); + std::string sdmc_directory = Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir); + std::string nand_directory = Common::FS::GetUserPath(Common::FS::UserPath::NANDDir); auto sdmc_factory = std::make_unique(sdmc_directory); if (sdmc_factory->Initialize()) RegisterArchiveType(std::move(sdmc_factory), ArchiveIdCode::SDMC); diff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cpp index 9c4c09fad..fb6462eef 100644 --- a/src/core/hle/service/ptm/ptm.cpp +++ b/src/core/hle/service/ptm/ptm.cpp @@ -134,7 +134,7 @@ void Module::Interface::CheckNew3DS(Kernel::HLERequestContext& ctx) { } static void WriteGameCoinData(GameCoin gamecoin_data) { - const std::string& nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); + const std::string& nand_directory = Common::FS::GetUserPath(Common::FS::UserPath::NANDDir); FileSys::ArchiveFactory_ExtSaveData extdata_archive_factory(nand_directory, true); FileSys::Path archive_path(ptm_shared_extdata_id); @@ -167,7 +167,7 @@ static void WriteGameCoinData(GameCoin gamecoin_data) { } static GameCoin ReadGameCoinData() { - const std::string& nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); + const std::string& nand_directory = Common::FS::GetUserPath(Common::FS::UserPath::NANDDir); FileSys::ArchiveFactory_ExtSaveData extdata_archive_factory(nand_directory, true); FileSys::Path archive_path(ptm_shared_extdata_id); @@ -197,7 +197,7 @@ static GameCoin ReadGameCoinData() { Module::Module() { // Open the SharedExtSaveData archive 0xF000000B and create the gamecoin.dat file if it doesn't // exist - const std::string& nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); + const std::string& nand_directory = Common::FS::GetUserPath(Common::FS::UserPath::NANDDir); FileSys::ArchiveFactory_ExtSaveData extdata_archive_factory(nand_directory, true); const FileSys::Path archive_path(ptm_shared_extdata_id); const auto archive_result = extdata_archive_factory.Open(archive_path, 0); diff --git a/src/core/hw/aes/key.cpp b/src/core/hw/aes/key.cpp index e406aed71..a113b9266 100644 --- a/src/core/hw/aes/key.cpp +++ b/src/core/hw/aes/key.cpp @@ -159,8 +159,8 @@ void LoadBootromKeys() { // by other applications e.g. process9. These normal keys thus aren't used by any application // and have no value for emulation - const std::string filepath = FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir) + BOOTROM9; - auto file = FileUtil::IOFile(filepath, "rb"); + const std::string filepath = Common::FS::GetUserPath(Common::FS::UserPath::SysDataDir) + BOOTROM9; + auto file = Common::FS::IOFile(filepath, "rb"); if (!file) { return; } @@ -310,8 +310,8 @@ void LoadNativeFirmKeysNew3DS() { // The first 0x10 bytes of the secret_sector are used as a key to decrypt a KeyX from the // native_firm const std::string filepath = - FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir) + SECRET_SECTOR; - auto secret = FileUtil::IOFile(filepath, "rb"); + Common::FS::GetUserPath(Common::FS::UserPath::SysDataDir) + SECRET_SECTOR; + auto secret = Common::FS::IOFile(filepath, "rb"); if (!secret) { return; } @@ -426,8 +426,8 @@ void LoadNativeFirmKeysNew3DS() { } void LoadPresetKeys() { - const std::string filepath = FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir) + AES_KEYS; - FileUtil::CreateFullPath(filepath); // Create path if not already created + const std::string filepath = Common::FS::GetUserPath(Common::FS::UserPath::SysDataDir) + AES_KEYS; + Common::FS::CreateFullPath(filepath); // Create path if not already created std::ifstream file; OpenFStream(file, filepath, std::ios_base::in); if (!file) { diff --git a/src/core/hw/rsa/rsa.cpp b/src/core/hw/rsa/rsa.cpp index b4179fd69..e1dd0b971 100644 --- a/src/core/hw/rsa/rsa.cpp +++ b/src/core/hw/rsa/rsa.cpp @@ -52,8 +52,8 @@ void InitSlots() { return; initialized = true; - const std::string filepath = FileUtil::GetUserPath(FileUtil::UserPath::SysDataDir) + BOOTROM9; - FileUtil::IOFile file(filepath, "rb"); + const std::string filepath = Common::FS::GetUserPath(Common::FS::UserPath::SysDataDir) + BOOTROM9; + Common::FS::IOFile file(filepath, "rb"); if (!file) { return; } diff --git a/src/core/loader/3dsx.cpp b/src/core/loader/3dsx.cpp index 99d920951..a1d53915c 100644 --- a/src/core/loader/3dsx.cpp +++ b/src/core/loader/3dsx.cpp @@ -94,7 +94,7 @@ static u32 TranslateAddr(u32 addr, const THREEloadinfo* loadinfo, u32* offsets) using Kernel::CodeSet; -static THREEDSX_Error Load3DSXFile(FileUtil::IOFile& file, u32 base_addr, +static THREEDSX_Error Load3DSXFile(Common::FS::IOFile& file, u32 base_addr, std::shared_ptr* out_codeset) { if (!file.IsOpen()) return ERROR_FILE; @@ -248,7 +248,7 @@ static THREEDSX_Error Load3DSXFile(FileUtil::IOFile& file, u32 base_addr, return ERROR_NONE; } -FileType AppLoader_THREEDSX::IdentifyType(FileUtil::IOFile& file) { +FileType AppLoader_THREEDSX::IdentifyType(Common::FS::IOFile& file) { u32 magic; file.Seek(0, SEEK_SET); if (1 != file.ReadArray(&magic, 1)) @@ -315,7 +315,7 @@ ResultStatus AppLoader_THREEDSX::ReadRomFS(std::shared_ptr LOG_DEBUG(Loader, "RomFS size: {:#010X}", romfs_size); // We reopen the file, to allow its position to be independent from file's - FileUtil::IOFile romfs_file_inner(filepath, "rb"); + Common::FS::IOFile romfs_file_inner(filepath, "rb"); if (!romfs_file_inner.IsOpen()) return ResultStatus::Error; diff --git a/src/core/loader/3dsx.h b/src/core/loader/3dsx.h index 4d56a0624..804e8bf72 100644 --- a/src/core/loader/3dsx.h +++ b/src/core/loader/3dsx.h @@ -17,16 +17,16 @@ namespace Loader { /// Loads an 3DSX file class AppLoader_THREEDSX final : public AppLoader { public: - AppLoader_THREEDSX(FileUtil::IOFile&& file, const std::string& filename, + AppLoader_THREEDSX(Common::FS::IOFile&& file, const std::string& filename, const std::string& filepath) : AppLoader(std::move(file)), filename(std::move(filename)), filepath(filepath) {} /** * Returns the type of the file - * @param file FileUtil::IOFile open file + * @param file Common::FS::IOFile open file * @return FileType found, or FileType::Error if this loader doesn't know it */ - static FileType IdentifyType(FileUtil::IOFile& file); + static FileType IdentifyType(Common::FS::IOFile& file); FileType GetFileType() override { return IdentifyType(file); diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp index 2527471df..f65c1a93b 100644 --- a/src/core/loader/elf.cpp +++ b/src/core/loader/elf.cpp @@ -364,7 +364,7 @@ SectionID ElfReader::GetSectionByName(const char* name, int firstSection) const namespace Loader { -FileType AppLoader_ELF::IdentifyType(FileUtil::IOFile& file) { +FileType AppLoader_ELF::IdentifyType(Common::FS::IOFile& file) { u32 magic; file.Seek(0, SEEK_SET); if (1 != file.ReadArray(&magic, 1)) diff --git a/src/core/loader/elf.h b/src/core/loader/elf.h index a43edff41..5f0ef2f15 100644 --- a/src/core/loader/elf.h +++ b/src/core/loader/elf.h @@ -17,15 +17,15 @@ namespace Loader { /// Loads an ELF/AXF file class AppLoader_ELF final : public AppLoader { public: - AppLoader_ELF(FileUtil::IOFile&& file, std::string filename) + AppLoader_ELF(Common::FS::IOFile&& file, std::string filename) : AppLoader(std::move(file)), filename(std::move(filename)) {} /** * Returns the type of the file - * @param file FileUtil::IOFile open file + * @param file Common::FS::IOFile open file * @return FileType found, or FileType::Error if this loader doesn't know it */ - static FileType IdentifyType(FileUtil::IOFile& file); + static FileType IdentifyType(Common::FS::IOFile& file); FileType GetFileType() override { return IdentifyType(file); diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index 9a172f9fd..061ee8ef5 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp @@ -15,7 +15,7 @@ namespace Loader { -FileType IdentifyFile(FileUtil::IOFile& file) { +FileType IdentifyFile(Common::FS::IOFile& file) { FileType type; #define CHECK_TYPE(loader) \ @@ -33,7 +33,7 @@ FileType IdentifyFile(FileUtil::IOFile& file) { } FileType IdentifyFile(const std::string& file_name) { - FileUtil::IOFile file(file_name, "rb"); + Common::FS::IOFile file(file_name, "rb"); if (!file.IsOpen()) { LOG_ERROR(Loader, "Failed to load file {}", file_name); return FileType::Unknown; @@ -91,7 +91,7 @@ const char* GetFileTypeString(FileType type) { * @param filepath the file full path (with name) * @return std::unique_ptr a pointer to a loader object; nullptr for unsupported type */ -static std::unique_ptr GetFileLoader(FileUtil::IOFile&& file, FileType type, +static std::unique_ptr GetFileLoader(Common::FS::IOFile&& file, FileType type, const std::string& filename, const std::string& filepath) { switch (type) { @@ -115,7 +115,7 @@ static std::unique_ptr GetFileLoader(FileUtil::IOFile&& file, FileTyp } std::unique_ptr GetLoader(const std::string& filename) { - FileUtil::IOFile file(filename, "rb"); + Common::FS::IOFile file(filename, "rb"); if (!file.IsOpen()) { LOG_ERROR(Loader, "Failed to load file {}", filename); return nullptr; diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h index d42aab3a1..d0fae4dd6 100644 --- a/src/core/loader/loader.h +++ b/src/core/loader/loader.h @@ -41,7 +41,7 @@ enum class FileType { * @param file open file * @return FileType of file */ -FileType IdentifyFile(FileUtil::IOFile& file); +FileType IdentifyFile(Common::FS::IOFile& file); /** * Identifies the type of a bootable file based on the magic value in its header. @@ -84,7 +84,7 @@ constexpr u32 MakeMagic(char a, char b, char c, char d) { /// Interface for loading an application class AppLoader : NonCopyable { public: - explicit AppLoader(FileUtil::IOFile&& file) : file(std::move(file)) {} + explicit AppLoader(Common::FS::IOFile&& file) : file(std::move(file)) {} virtual ~AppLoader() {} /** @@ -232,7 +232,7 @@ public: } protected: - FileUtil::IOFile file; + Common::FS::IOFile file; bool is_loaded = false; }; diff --git a/src/core/loader/ncch.cpp b/src/core/loader/ncch.cpp index e376120a7..99ad58f18 100644 --- a/src/core/loader/ncch.cpp +++ b/src/core/loader/ncch.cpp @@ -34,7 +34,7 @@ namespace Loader { static const u64 UPDATE_MASK = 0x0000000e00000000; -FileType AppLoader_NCCH::IdentifyType(FileUtil::IOFile& file) { +FileType AppLoader_NCCH::IdentifyType(Common::FS::IOFile& file) { u32 magic; file.Seek(0x100, SEEK_SET); if (1 != file.ReadArray(&magic, 1)) diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h index 6f680b063..d4b53f833 100644 --- a/src/core/loader/ncch.h +++ b/src/core/loader/ncch.h @@ -18,16 +18,16 @@ namespace Loader { /// Loads an NCCH file (e.g. from a CCI, or the first NCCH in a CXI) class AppLoader_NCCH final : public AppLoader { public: - AppLoader_NCCH(FileUtil::IOFile&& file, const std::string& filepath) + AppLoader_NCCH(Common::FS::IOFile&& file, const std::string& filepath) : AppLoader(std::move(file)), base_ncch(filepath), overlay_ncch(&base_ncch), filepath(filepath) {} /** * Returns the type of the file - * @param file FileUtil::IOFile open file + * @param file Common::FS::IOFile open file * @return FileType found, or FileType::Error if this loader doesn't know it */ - static FileType IdentifyType(FileUtil::IOFile& file); + static FileType IdentifyType(Common::FS::IOFile& file); FileType GetFileType() override { return IdentifyType(file); diff --git a/src/core/movie.cpp b/src/core/movie.cpp index c199443aa..faf2667a7 100644 --- a/src/core/movie.cpp +++ b/src/core/movie.cpp @@ -483,7 +483,7 @@ Movie::ValidationResult Movie::ValidateInput(const std::vector& input, void Movie::SaveMovie() { LOG_INFO(Movie, "Saving recorded movie to '{}'", record_movie_file); - FileUtil::IOFile save_record(record_movie_file, "wb"); + Common::FS::IOFile save_record(record_movie_file, "wb"); if (!save_record.IsGood()) { LOG_ERROR(Movie, "Unable to open file to save movie"); @@ -521,7 +521,7 @@ void Movie::SetPlaybackCompletionCallback(std::function completion_callb void Movie::StartPlayback(const std::string& movie_file) { LOG_INFO(Movie, "Loading Movie for playback"); - FileUtil::IOFile save_record(movie_file, "rb"); + Common::FS::IOFile save_record(movie_file, "rb"); const u64 size = save_record.GetSize(); if (save_record.IsGood() && size > sizeof(CTMHeader)) { @@ -575,7 +575,7 @@ void Movie::SetReadOnly(bool read_only_) { } static boost::optional ReadHeader(const std::string& movie_file) { - FileUtil::IOFile save_record(movie_file, "rb"); + Common::FS::IOFile save_record(movie_file, "rb"); const u64 size = save_record.GetSize(); if (!save_record || size <= sizeof(CTMHeader)) { @@ -609,7 +609,7 @@ void Movie::PrepareForRecording() { Movie::ValidationResult Movie::ValidateMovie(const std::string& movie_file) const { LOG_INFO(Movie, "Validating Movie file '{}'", movie_file); - FileUtil::IOFile save_record(movie_file, "rb"); + Common::FS::IOFile save_record(movie_file, "rb"); const u64 size = save_record.GetSize(); if (!save_record || size <= sizeof(CTMHeader)) { diff --git a/src/core/perf_stats.cpp b/src/core/perf_stats.cpp index 5b426c83b..0d8900c8e 100644 --- a/src/core/perf_stats.cpp +++ b/src/core/perf_stats.cpp @@ -38,11 +38,11 @@ PerfStats::~PerfStats() { std::ostringstream stream; std::copy(perf_history.begin() + IgnoreFrames, perf_history.begin() + current_index, std::ostream_iterator(stream, "\n")); - const std::string& path = FileUtil::GetUserPath(FileUtil::UserPath::LogDir); + const std::string& path = Common::FS::GetUserPath(Common::FS::UserPath::LogDir); // %F Date format expanded is "%Y-%m-%d" const std::string filename = fmt::format("{}/{:%F-%H-%M}_{:016X}.csv", path, *std::localtime(&t), title_id); - FileUtil::IOFile file(filename, "w"); + Common::FS::IOFile file(filename, "w"); file.WriteString(stream.str()); } diff --git a/src/core/savestate.cpp b/src/core/savestate.cpp index 1ab245570..1b02708d8 100644 --- a/src/core/savestate.cpp +++ b/src/core/savestate.cpp @@ -41,11 +41,11 @@ std::string GetSaveStatePath(u64 program_id, u32 slot) { const u64 movie_id = Movie::GetInstance().GetCurrentMovieID(); if (movie_id) { return fmt::format("{}{:016X}.movie{:016X}.{:02d}.cst", - FileUtil::GetUserPath(FileUtil::UserPath::StatesDir), program_id, + Common::FS::GetUserPath(Common::FS::UserPath::StatesDir), program_id, movie_id, slot); } else { return fmt::format("{}{:016X}.{:02d}.cst", - FileUtil::GetUserPath(FileUtil::UserPath::StatesDir), program_id, slot); + Common::FS::GetUserPath(Common::FS::UserPath::StatesDir), program_id, slot); } } @@ -53,14 +53,14 @@ std::vector ListSaveStates(u64 program_id) { std::vector result; for (u32 slot = 1; slot <= SaveStateSlotCount; ++slot) { const auto path = GetSaveStatePath(program_id, slot); - if (!FileUtil::Exists(path)) { + if (!Common::FS::Exists(path)) { continue; } SaveStateInfo info; info.slot = slot; - FileUtil::IOFile file(path, "rb"); + Common::FS::IOFile file(path, "rb"); if (!file) { LOG_ERROR(Core, "Could not open file {}", path); continue; @@ -108,11 +108,11 @@ void System::SaveState(u32 slot) const { reinterpret_cast(str.data()), str.size()); const auto path = GetSaveStatePath(title_id, slot); - if (!FileUtil::CreateFullPath(path)) { + if (!Common::FS::CreateFullPath(path)) { throw std::runtime_error("Could not create path " + path); } - FileUtil::IOFile file(path, "wb"); + Common::FS::IOFile file(path, "wb"); if (!file) { throw std::runtime_error("Could not open file " + path); } @@ -143,9 +143,9 @@ void System::LoadState(u32 slot) { std::vector decompressed; { - std::vector buffer(FileUtil::GetSize(path) - sizeof(CSTHeader)); + std::vector buffer(Common::FS::GetSize(path) - sizeof(CSTHeader)); - FileUtil::IOFile file(path, "rb"); + Common::FS::IOFile file(path, "rb"); file.Seek(sizeof(CSTHeader), SEEK_SET); // Skip header if (file.ReadBytes(buffer.data(), buffer.size()) != buffer.size()) { throw std::runtime_error("Could not read from file at " + path); diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 2f247305d..ef2902ab4 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -131,8 +131,8 @@ void LogSettings() { LogSetting("DataStorage_UseVirtualSd", values.use_virtual_sd); LogSetting("DataStorage_UseCustomStorage", values.use_custom_storage); if (values.use_custom_storage) { - LogSetting("DataStorage_SdmcDir", FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)); - LogSetting("DataStorage_NandDir", FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)); + LogSetting("DataStorage_SdmcDir", Common::FS::GetUserPath(Common::FS::UserPath::SDMCDir)); + LogSetting("DataStorage_NandDir", Common::FS::GetUserPath(Common::FS::UserPath::NANDDir)); } LogSetting("System_IsNew3ds", values.is_new_3ds); LogSetting("System_RegionValue", values.region_value); diff --git a/src/core/telemetry_session.cpp b/src/core/telemetry_session.cpp index 318e3f69b..fb1957d2d 100644 --- a/src/core/telemetry_session.cpp +++ b/src/core/telemetry_session.cpp @@ -29,18 +29,18 @@ static u64 GenerateTelemetryId() { u64 GetTelemetryId() { u64 telemetry_id{}; - const std::string filename{FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + + const std::string filename{Common::FS::GetUserPath(Common::FS::UserPath::ConfigDir) + "telemetry_id"}; - if (FileUtil::Exists(filename)) { - FileUtil::IOFile file(filename, "rb"); + if (Common::FS::Exists(filename)) { + Common::FS::IOFile file(filename, "rb"); if (!file.IsOpen()) { LOG_ERROR(Core, "failed to open telemetry_id: {}", filename); return {}; } file.ReadBytes(&telemetry_id, sizeof(u64)); } else { - FileUtil::IOFile file(filename, "wb"); + Common::FS::IOFile file(filename, "wb"); if (!file.IsOpen()) { LOG_ERROR(Core, "failed to open telemetry_id: {}", filename); return {}; @@ -54,10 +54,10 @@ u64 GetTelemetryId() { u64 RegenerateTelemetryId() { const u64 new_telemetry_id{GenerateTelemetryId()}; - const std::string filename{FileUtil::GetUserPath(FileUtil::UserPath::ConfigDir) + + const std::string filename{Common::FS::GetUserPath(Common::FS::UserPath::ConfigDir) + "telemetry_id"}; - FileUtil::IOFile file(filename, "wb"); + Common::FS::IOFile file(filename, "wb"); if (!file.IsOpen()) { LOG_ERROR(Core, "failed to open telemetry_id: {}", filename); return {}; diff --git a/src/core/tracer/recorder.cpp b/src/core/tracer/recorder.cpp index ca24ba149..95c061b30 100644 --- a/src/core/tracer/recorder.cpp +++ b/src/core/tracer/recorder.cpp @@ -75,7 +75,7 @@ void Recorder::Finish(const std::string& filename) { try { // Open file and write header - FileUtil::IOFile file(filename, "wb"); + Common::FS::IOFile file(filename, "wb"); std::size_t written = file.WriteObject(header); if (written != 1 || file.Tell() != initial.gpu_registers) throw "Failed to write header"; diff --git a/src/dedicated_room/citra-room.cpp b/src/dedicated_room/citra-room.cpp index fe0da34c6..747edd95b 100644 --- a/src/dedicated_room/citra-room.cpp +++ b/src/dedicated_room/citra-room.cpp @@ -153,8 +153,8 @@ static void SaveBanList(const Network::Room::BanList& ban_list, const std::strin static void InitializeLogging(const std::string& log_file) { Log::AddBackend(std::make_unique()); - const std::string& log_dir = FileUtil::GetUserPath(FileUtil::UserPath::LogDir); - FileUtil::CreateFullPath(log_dir); + const std::string& log_dir = Common::FS::GetUserPath(Common::FS::UserPath::LogDir); + Common::FS::CreateFullPath(log_dir); Log::AddBackend(std::make_unique(log_dir + log_file)); #ifdef _WIN32 diff --git a/src/tests/core/file_sys/path_parser.cpp b/src/tests/core/file_sys/path_parser.cpp index 6401fff91..9e48776b1 100644 --- a/src/tests/core/file_sys/path_parser.cpp +++ b/src/tests/core/file_sys/path_parser.cpp @@ -22,9 +22,9 @@ TEST_CASE("PathParser", "[core][file_sys]") { TEST_CASE("PathParser - Host file system", "[core][file_sys]") { std::string test_dir = "./test"; - FileUtil::CreateDir(test_dir); - FileUtil::CreateDir(test_dir + "/z"); - FileUtil::CreateEmptyFile(test_dir + "/a"); + Common::FS::CreateDir(test_dir); + Common::FS::CreateDir(test_dir + "/z"); + Common::FS::CreateEmptyFile(test_dir + "/a"); REQUIRE(PathParser(Path("/a")).GetHostStatus(test_dir) == PathParser::FileFound); REQUIRE(PathParser(Path("/b")).GetHostStatus(test_dir) == PathParser::NotFound); @@ -32,7 +32,7 @@ TEST_CASE("PathParser - Host file system", "[core][file_sys]") { REQUIRE(PathParser(Path("/a/c")).GetHostStatus(test_dir) == PathParser::FileInPath); REQUIRE(PathParser(Path("/b/c")).GetHostStatus(test_dir) == PathParser::PathNotFound); - FileUtil::DeleteDirRecursively(test_dir); + Common::FS::DeleteDirRecursively(test_dir); } } // namespace FileSys diff --git a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp index f2b0757d3..9daf9f43d 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.cpp @@ -47,7 +47,7 @@ ShaderDiskCacheRaw::ShaderDiskCacheRaw(u64 unique_identifier, ProgramType progra : unique_identifier{unique_identifier}, program_type{program_type}, config{config}, program_code{std::move(program_code)} {} -bool ShaderDiskCacheRaw::Load(FileUtil::IOFile& file) { +bool ShaderDiskCacheRaw::Load(Common::FS::IOFile& file) { if (file.ReadBytes(&unique_identifier, sizeof(u64)) != sizeof(u64) || file.ReadBytes(&program_type, sizeof(u32)) != sizeof(u32)) { return false; @@ -77,7 +77,7 @@ bool ShaderDiskCacheRaw::Load(FileUtil::IOFile& file) { return true; } -bool ShaderDiskCacheRaw::Save(FileUtil::IOFile& file) const { +bool ShaderDiskCacheRaw::Save(Common::FS::IOFile& file) const { if (file.WriteObject(unique_identifier) != 1 || file.WriteObject(static_cast(program_type)) != 1) { return false; @@ -114,7 +114,7 @@ std::optional> ShaderDiskCache::LoadTransferable } tried_to_load = true; - FileUtil::IOFile file(GetTransferablePath(), "rb"); + Common::FS::IOFile file(GetTransferablePath(), "rb"); if (!file.IsOpen()) { LOG_INFO(Render_OpenGL, "No transferable shader cache found for game with title id={}", GetTitleID()); @@ -177,7 +177,7 @@ ShaderDiskCache::LoadPrecompiled(bool compressed) { if (!IsUsable()) return {}; - FileUtil::IOFile file(GetPrecompiledPath(), "rb"); + Common::FS::IOFile file(GetPrecompiledPath(), "rb"); if (!file.IsOpen()) { LOG_INFO(Render_OpenGL, "No precompiled shader cache found for game with title id={}", GetTitleID()); @@ -197,7 +197,7 @@ ShaderDiskCache::LoadPrecompiled(bool compressed) { } std::optional, ShaderDumpsMap>> -ShaderDiskCache::LoadPrecompiledFile(FileUtil::IOFile& file, bool compressed) { +ShaderDiskCache::LoadPrecompiledFile(Common::FS::IOFile& file, bool compressed) { // Read compressed file from disk and decompress to virtual precompiled cache file std::vector precompiled_file(file.GetSize()); file.ReadBytes(precompiled_file.data(), precompiled_file.size()); @@ -301,7 +301,7 @@ std::optional ShaderDiskCache::LoadDecompiledEntry() return entry; } -void ShaderDiskCache::SaveDecompiledToFile(FileUtil::IOFile& file, u64 unique_identifier, +void ShaderDiskCache::SaveDecompiledToFile(Common::FS::IOFile& file, u64 unique_identifier, const ShaderDecompiler::ProgramResult& result, bool sanitize_mul) { if (!IsUsable()) @@ -331,7 +331,7 @@ bool ShaderDiskCache::SaveDecompiledToCache(u64 unique_identifier, } void ShaderDiskCache::InvalidateAll() { - if (!FileUtil::Delete(GetTransferablePath())) { + if (!Common::FS::Delete(GetTransferablePath())) { LOG_ERROR(Render_OpenGL, "Failed to invalidate transferable file={}", GetTransferablePath()); } @@ -342,7 +342,7 @@ void ShaderDiskCache::InvalidatePrecompiled() { // Clear virtual precompiled cache file decompressed_precompiled_cache.resize(0); - if (!FileUtil::Delete(GetPrecompiledPath())) { + if (!Common::FS::Delete(GetPrecompiledPath())) { LOG_ERROR(Render_OpenGL, "Failed to invalidate precompiled file={}", GetPrecompiledPath()); } } @@ -357,7 +357,7 @@ void ShaderDiskCache::SaveRaw(const ShaderDiskCacheRaw& entry) { return; } - FileUtil::IOFile file = AppendTransferableFile(); + Common::FS::IOFile file = AppendTransferableFile(); if (!file.IsOpen()) return; if (file.WriteObject(TransferableEntryKind::Raw) != 1 || !entry.Save(file)) { @@ -413,7 +413,7 @@ void ShaderDiskCache::SaveDumpToFile(u64 unique_identifier, GLuint program, bool if (!IsUsable()) return; - FileUtil::IOFile file = AppendPrecompiledFile(); + Common::FS::IOFile file = AppendPrecompiledFile(); if (!file.IsOpen()) return; @@ -444,14 +444,14 @@ bool ShaderDiskCache::IsUsable() const { return tried_to_load && Settings::values.use_disk_shader_cache; } -FileUtil::IOFile ShaderDiskCache::AppendTransferableFile() { +Common::FS::IOFile ShaderDiskCache::AppendTransferableFile() { if (!EnsureDirectories()) return {}; const auto transferable_path{GetTransferablePath()}; - const bool existed = FileUtil::Exists(transferable_path); + const bool existed = Common::FS::Exists(transferable_path); - FileUtil::IOFile file(transferable_path, "ab"); + Common::FS::IOFile file(transferable_path, "ab"); if (!file.IsOpen()) { LOG_ERROR(Render_OpenGL, "Failed to open transferable cache in path={}", transferable_path); return {}; @@ -467,14 +467,14 @@ FileUtil::IOFile ShaderDiskCache::AppendTransferableFile() { return file; } -FileUtil::IOFile ShaderDiskCache::AppendPrecompiledFile() { +Common::FS::IOFile ShaderDiskCache::AppendPrecompiledFile() { if (!EnsureDirectories()) return {}; const auto precompiled_path{GetPrecompiledPath()}; - const bool existed = FileUtil::Exists(precompiled_path); + const bool existed = Common::FS::Exists(precompiled_path); - FileUtil::IOFile file(precompiled_path, "ab"); + Common::FS::IOFile file(precompiled_path, "ab"); if (!file.IsOpen()) { LOG_ERROR(Render_OpenGL, "Failed to open precompiled cache in path={}", precompiled_path); return {}; @@ -506,7 +506,7 @@ void ShaderDiskCache::SaveVirtualPrecompiledFile() { decompressed_precompiled_cache.data(), decompressed_precompiled_cache.size()); const auto precompiled_path{GetPrecompiledPath()}; - FileUtil::IOFile file(precompiled_path, "wb"); + Common::FS::IOFile file(precompiled_path, "wb"); if (!file.IsOpen()) { LOG_ERROR(Render_OpenGL, "Failed to open precompiled cache in path={}", precompiled_path); @@ -521,24 +521,24 @@ void ShaderDiskCache::SaveVirtualPrecompiledFile() { bool ShaderDiskCache::EnsureDirectories() const { const auto CreateDir = [](const std::string& dir) { - if (!FileUtil::CreateDir(dir)) { + if (!Common::FS::CreateDir(dir)) { LOG_ERROR(Render_OpenGL, "Failed to create directory={}", dir); return false; } return true; }; - return CreateDir(FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir)) && + return CreateDir(Common::FS::GetUserPath(Common::FS::UserPath::ShaderDir)) && CreateDir(GetBaseDir()) && CreateDir(GetTransferableDir()) && CreateDir(GetPrecompiledDir()) && CreateDir(GetPrecompiledShaderDir()); } std::string ShaderDiskCache::GetTransferablePath() { - return FileUtil::SanitizePath(GetTransferableDir() + DIR_SEP_CHR + GetTitleID() + ".bin"); + return Common::FS::SanitizePath(GetTransferableDir() + DIR_SEP_CHR + GetTitleID() + ".bin"); } std::string ShaderDiskCache::GetPrecompiledPath() { - return FileUtil::SanitizePath(GetPrecompiledShaderDir() + DIR_SEP_CHR + GetTitleID() + ".bin"); + return Common::FS::SanitizePath(GetPrecompiledShaderDir() + DIR_SEP_CHR + GetTitleID() + ".bin"); } std::string ShaderDiskCache::GetTransferableDir() const { @@ -557,7 +557,7 @@ std::string ShaderDiskCache::GetPrecompiledShaderDir() const { } std::string ShaderDiskCache::GetBaseDir() const { - return FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir) + DIR_SEP "opengl"; + return Common::FS::GetUserPath(Common::FS::UserPath::ShaderDir) + DIR_SEP "opengl"; } u64 ShaderDiskCache::GetProgramID() { diff --git a/src/video_core/renderer_opengl/gl_shader_disk_cache.h b/src/video_core/renderer_opengl/gl_shader_disk_cache.h index 5a2faeb9a..7831af284 100644 --- a/src/video_core/renderer_opengl/gl_shader_disk_cache.h +++ b/src/video_core/renderer_opengl/gl_shader_disk_cache.h @@ -27,7 +27,7 @@ namespace Core { class System; } -namespace FileUtil { +namespace Common::FS { class IOFile; } @@ -49,9 +49,9 @@ public: ShaderDiskCacheRaw() = default; ~ShaderDiskCacheRaw() = default; - bool Load(FileUtil::IOFile& file); + bool Load(Common::FS::IOFile& file); - bool Save(FileUtil::IOFile& file) const; + bool Save(Common::FS::IOFile& file) const; u64 GetUniqueIdentifier() const { return unique_identifier; @@ -124,14 +124,14 @@ public: private: /// Loads the transferable cache. Returns empty on failure. std::optional> LoadPrecompiledFile( - FileUtil::IOFile& file, bool compressed); + Common::FS::IOFile& file, bool compressed); /// Loads a decompiled cache entry from m_precompiled_cache_virtual_file. Returns empty on /// failure. std::optional LoadDecompiledEntry(); /// Saves a decompiled entry to the passed file. Does not check for collisions. - void SaveDecompiledToFile(FileUtil::IOFile& file, u64 unique_identifier, + void SaveDecompiledToFile(Common::FS::IOFile& file, u64 unique_identifier, const ShaderDecompiler::ProgramResult& code, bool sanitize_mul); /// Saves a decompiled entry to the virtual precompiled cache. Does not check for collisions. @@ -142,7 +142,7 @@ private: bool IsUsable() const; /// Opens current game's transferable file and write it's header if it doesn't exist - FileUtil::IOFile AppendTransferableFile(); + Common::FS::IOFile AppendTransferableFile(); /// Save precompiled header to precompiled_cache_in_memory void SavePrecompiledHeaderToVirtualPrecompiledCache(); @@ -223,7 +223,7 @@ private: u64 program_id{}; std::string title_id; - FileUtil::IOFile AppendPrecompiledFile(); + Common::FS::IOFile AppendPrecompiledFile(); }; } // namespace OpenGL diff --git a/src/video_core/renderer_opengl/post_processing_opengl.cpp b/src/video_core/renderer_opengl/post_processing_opengl.cpp index 80d8be7cb..142760d4a 100644 --- a/src/video_core/renderer_opengl/post_processing_opengl.cpp +++ b/src/video_core/renderer_opengl/post_processing_opengl.cpp @@ -123,17 +123,17 @@ void SetOutput(float4 color_in) )"; std::vector GetPostProcessingShaderList(bool anaglyph) { - std::string shader_dir = FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir); + std::string shader_dir = Common::FS::GetUserPath(Common::FS::UserPath::ShaderDir); std::vector shader_names; - if (!FileUtil::IsDirectory(shader_dir)) { - FileUtil::CreateDir(shader_dir); + if (!Common::FS::IsDirectory(shader_dir)) { + Common::FS::CreateDir(shader_dir); } if (anaglyph) { shader_dir = shader_dir + "anaglyph"; - if (!FileUtil::IsDirectory(shader_dir)) { - FileUtil::CreateDir(shader_dir); + if (!Common::FS::IsDirectory(shader_dir)) { + Common::FS::CreateDir(shader_dir); } } @@ -141,7 +141,7 @@ std::vector GetPostProcessingShaderList(bool anaglyph) { const auto callback = [&shader_names](u64* num_entries_out, const std::string& directory, const std::string& virtual_name) -> bool { const std::string physical_name = directory + DIR_SEP + virtual_name; - if (!FileUtil::IsDirectory(physical_name)) { + if (!Common::FS::IsDirectory(physical_name)) { // The following is done to avoid coupling this to Qt std::size_t dot_pos = virtual_name.rfind("."); if (dot_pos != std::string::npos) { @@ -153,7 +153,7 @@ std::vector GetPostProcessingShaderList(bool anaglyph) { return true; }; - FileUtil::ForeachDirectoryEntry(nullptr, shader_dir, callback); + Common::FS::ForeachDirectoryEntry(nullptr, shader_dir, callback); std::sort(shader_names.begin(), shader_names.end()); @@ -161,7 +161,7 @@ std::vector GetPostProcessingShaderList(bool anaglyph) { } std::string GetPostProcessingShaderCode(bool anaglyph, std::string_view shader) { - std::string shader_dir = FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir); + std::string shader_dir = Common::FS::GetUserPath(Common::FS::UserPath::ShaderDir); std::string shader_path; if (anaglyph) { @@ -174,7 +174,7 @@ std::string GetPostProcessingShaderCode(bool anaglyph, std::string_view shader) const std::string& directory, const std::string& virtual_name) -> bool { const std::string physical_name = directory + DIR_SEP + virtual_name; - if (!FileUtil::IsDirectory(physical_name)) { + if (!Common::FS::IsDirectory(physical_name)) { // The following is done to avoid coupling this to Qt std::size_t dot_pos = virtual_name.rfind("."); if (dot_pos != std::string::npos) { @@ -188,7 +188,7 @@ std::string GetPostProcessingShaderCode(bool anaglyph, std::string_view shader) return true; }; - FileUtil::ForeachDirectoryEntry(nullptr, shader_dir, callback); + Common::FS::ForeachDirectoryEntry(nullptr, shader_dir, callback); if (shader_path.empty()) { return ""; } diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 3ac9c6b27..bb215ee06 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -106,7 +106,7 @@ void PipelineCache::LoadDiskCache() { vk::PipelineCacheCreateInfo cache_info = {.initialDataSize = 0, .pInitialData = nullptr}; std::vector cache_data; - FileUtil::IOFile cache_file{cache_file_path, "r"}; + Common::FS::IOFile cache_file{cache_file_path, "r"}; if (cache_file.IsOpen()) { LOG_INFO(Render_Vulkan, "Loading pipeline cache"); @@ -135,7 +135,7 @@ void PipelineCache::SaveDiskCache() { const std::string cache_file_path = fmt::format("{}{:x}{:x}.bin", GetPipelineCacheDir(), instance.GetVendorID(), instance.GetDeviceID()); - FileUtil::IOFile cache_file{cache_file_path, "wb"}; + Common::FS::IOFile cache_file{cache_file_path, "wb"}; if (!cache_file.IsOpen()) { LOG_INFO(Render_Vulkan, "Unable to open pipeline cache for writing"); return; @@ -582,7 +582,7 @@ bool PipelineCache::IsCacheValid(const u8* data, u64 size) const { bool PipelineCache::EnsureDirectories() const { const auto CreateDir = [](const std::string& dir) { - if (!FileUtil::CreateDir(dir)) { + if (!Common::FS::CreateDir(dir)) { LOG_ERROR(Render_Vulkan, "Failed to create directory={}", dir); return false; } @@ -590,12 +590,12 @@ bool PipelineCache::EnsureDirectories() const { return true; }; - return CreateDir(FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir)) && + return CreateDir(Common::FS::GetUserPath(Common::FS::UserPath::ShaderDir)) && CreateDir(GetPipelineCacheDir()); } std::string PipelineCache::GetPipelineCacheDir() const { - return FileUtil::GetUserPath(FileUtil::UserPath::ShaderDir) + "vulkan" + DIR_SEP; + return Common::FS::GetUserPath(Common::FS::UserPath::ShaderDir) + "vulkan" + DIR_SEP; } } // namespace Vulkan