diff --git a/src/android/app/src/main/jni/game_metadata.cpp b/src/android/app/src/main/jni/game_metadata.cpp index 9acba456f1..ce520d68dd 100644 --- a/src/android/app/src/main/jni/game_metadata.cpp +++ b/src/android/app/src/main/jni/game_metadata.cpp @@ -80,7 +80,7 @@ extern "C" { jboolean Java_org_yuzu_yuzu_1emu_utils_GameMetadata_getIsValid(JNIEnv* env, jobject obj, jstring jpath) { - const auto file = EmulationSession::GetInstance().System().GetFilesystem()->OpenFile( + const auto file = EmulationSession::GetInstance().System().GetFilesystem()->OpenFileHandle( Common::Android::GetJString(env, jpath), FileSys::OpenMode::Read); if (!file) { return false; diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 210689ce55..25818d093b 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -211,7 +211,7 @@ void EmulationSession::SurfaceChanged() { } void EmulationSession::ConfigureFilesystemProvider(const std::string& filepath) { - const auto file = m_system.GetFilesystem()->OpenFile(filepath, FileSys::OpenMode::Read); + const auto file = m_system.GetFilesystem()->OpenFileHandle(filepath, FileSys::OpenMode::Read); if (!file) { return; } @@ -724,7 +724,7 @@ jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_doesUpdateMatchProgram(JNIEnv* en u64 program_id = EmulationSession::GetProgramId(env, jprogramId); std::string updatePath = Common::Android::GetJString(env, jupdatePath); std::shared_ptr nsp = std::make_shared( - EmulationSession::GetInstance().System().GetFilesystem()->OpenFile( + EmulationSession::GetInstance().System().GetFilesystem()->OpenFileHandle( updatePath, FileSys::OpenMode::Read)); for (const auto& item : nsp->GetNCAs()) { for (const auto& nca_details : item.second) { @@ -1243,7 +1243,7 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_submitInlineKeyboardInput(JNIEnv* env void Java_org_yuzu_yuzu_1emu_NativeLibrary_initializeEmptyUserDirectory(JNIEnv* env, jobject instance) { const auto nand_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::NANDDir); - auto vfs_nand_dir = EmulationSession::GetInstance().System().GetFilesystem()->OpenDirectory( + auto vfs_nand_dir = EmulationSession::GetInstance().System().GetFilesystem()->OpenDirectoryHandle( Common::FS::PathToUTF8String(nand_dir), FileSys::OpenMode::Read); const auto user_id = EmulationSession::GetInstance().System().GetProfileManager().GetUser( @@ -1488,7 +1488,7 @@ jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getSavePath(JNIEnv* env, jobject j ASSERT(user_id); const auto saveDir = Common::FS::GetEdenPath(Common::FS::EdenPath::SaveDir); - auto vfsSaveDir = system.GetFilesystem()->OpenDirectory(Common::FS::PathToUTF8String(saveDir), + auto vfsSaveDir = system.GetFilesystem()->OpenDirectoryHandle(Common::FS::PathToUTF8String(saveDir), FileSys::OpenMode::Read); const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( diff --git a/src/core/core.cpp b/src/core/core.cpp index 2c8cbe21bb..826cada573 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -75,7 +75,7 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, Common::SplitPath(path, &dir_name, &filename, nullptr); if (filename == "00") { - const auto dir = vfs->OpenDirectory(dir_name, FileSys::OpenMode::Read); + const auto dir = vfs->OpenDirectoryHandle(dir_name, FileSys::OpenMode::Read); std::vector concat; for (u32 i = 0; i < 0x10; ++i) { @@ -100,10 +100,10 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, } if (Common::FS::IsDir(path)) { - return vfs->OpenFile(path + "/main", FileSys::OpenMode::Read); + return vfs->OpenFileHandle(path + "/main", FileSys::OpenMode::Read); } - return vfs->OpenFile(path, FileSys::OpenMode::Read); + return vfs->OpenFileHandle(path, FileSys::OpenMode::Read); } struct System::Impl { diff --git a/src/core/file_sys/bis_factory.cpp b/src/core/file_sys/bis_factory.cpp index 6facd03f6d..fea8b95be5 100644 --- a/src/core/file_sys/bis_factory.cpp +++ b/src/core/file_sys/bis_factory.cpp @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -82,7 +85,7 @@ VirtualDir BISFactory::OpenPartition(BisPartitionId id) const { VirtualFile BISFactory::OpenPartitionStorage(BisPartitionId id, VirtualFilesystem file_system) const { auto& keys = Core::Crypto::KeyManager::Instance(); - Core::Crypto::PartitionDataManager pdm{file_system->OpenDirectory( + Core::Crypto::PartitionDataManager pdm{file_system->OpenDirectoryHandle( Common::FS::GetEdenPathString(Common::FS::EdenPath::NANDDir), OpenMode::Read)}; keys.PopulateFromPartitionData(pdm); diff --git a/src/core/file_sys/fsa/fs_i_filesystem.h b/src/core/file_sys/fsa/fs_i_filesystem.h index 8172190f49..0d89e94d18 100644 --- a/src/core/file_sys/fsa/fs_i_filesystem.h +++ b/src/core/file_sys/fsa/fs_i_filesystem.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -27,20 +30,20 @@ public: explicit IFileSystem(VirtualDir backend_) : backend{std::move(backend_)} {} virtual ~IFileSystem() {} - Result CreateFile(const Path& path, s64 size, CreateOption option) { + Result CreateAndOpenFile(const Path& path, s64 size, CreateOption option) { R_UNLESS(size >= 0, ResultOutOfRange); R_RETURN(this->DoCreateFile(path, size, static_cast(option))); } - Result CreateFile(const Path& path, s64 size) { - R_RETURN(this->CreateFile(path, size, CreateOption::None)); + Result CreateAndOpenFile(const Path& path, s64 size) { + R_RETURN(this->CreateAndOpenFile(path, size, CreateOption::None)); } - Result DeleteFile(const Path& path) { + Result DeleteAndUnlinkFile(const Path& path) { R_RETURN(this->DoDeleteFile(path)); } - Result CreateDirectory(const Path& path) { + Result CreateAndOpenDirectory(const Path& path) { R_RETURN(this->DoCreateDirectory(path)); } @@ -64,14 +67,14 @@ public: R_RETURN(this->DoGetEntryType(out, path)); } - Result OpenFile(VirtualFile* out_file, const Path& path, OpenMode mode) { + Result OpenFileHandle(VirtualFile* out_file, const Path& path, OpenMode mode) { R_UNLESS(out_file != nullptr, ResultNullptrArgument); R_UNLESS(static_cast(mode & OpenMode::ReadWrite) != 0, ResultInvalidOpenMode); R_UNLESS(static_cast(mode & ~OpenMode::All) == 0, ResultInvalidOpenMode); R_RETURN(this->DoOpenFile(out_file, path, mode)); } - Result OpenDirectory(VirtualDir* out_dir, const Path& path, OpenDirectoryMode mode) { + Result OpenDirectoryHandle(VirtualDir* out_dir, const Path& path, OpenDirectoryMode mode) { R_UNLESS(out_dir != nullptr, ResultNullptrArgument); R_UNLESS(static_cast(mode & OpenDirectoryMode::All) != 0, ResultInvalidOpenMode); R_UNLESS(static_cast( @@ -123,15 +126,15 @@ public: private: Result DoCreateFile(const Path& path, s64 size, int flags) { - R_RETURN(backend.CreateFile(path.GetString(), size)); + R_RETURN(backend.CreateAndOpenFile(path.GetString(), size)); } Result DoDeleteFile(const Path& path) { - R_RETURN(backend.DeleteFile(path.GetString())); + R_RETURN(backend.DeleteAndUnlinkFile(path.GetString())); } Result DoCreateDirectory(const Path& path) { - R_RETURN(backend.CreateDirectory(path.GetString())); + R_RETURN(backend.CreateAndOpenDirectory(path.GetString())); } Result DoDeleteDirectory(const Path& path) { @@ -155,11 +158,11 @@ private: } Result DoOpenFile(VirtualFile* out_file, const Path& path, OpenMode mode) { - R_RETURN(backend.OpenFile(out_file, path.GetString(), mode)); + R_RETURN(backend.OpenFileHandle(out_file, path.GetString(), mode)); } Result DoOpenDirectory(VirtualDir* out_directory, const Path& path, OpenDirectoryMode mode) { - R_RETURN(backend.OpenDirectory(out_directory, path.GetString())); + R_RETURN(backend.OpenDirectoryHandle(out_directory, path.GetString())); } Result DoCommit() { diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index 6af926eac0..94e41dad63 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp @@ -403,7 +403,7 @@ std::vector PatchManager::PatchNSO(const std::vector& nso, const std::st const auto dump_dir = fs_controller.GetModificationDumpRoot(title_id); if (dump_dir != nullptr) { const auto nso_dir = GetOrCreateDirectoryRelative(dump_dir, "/nso"); - const auto file = nso_dir->CreateFile(fmt::format("{}-{}.nso", name, build_id)); + const auto file = nso_dir->CreateAndOpenFile(fmt::format("{}-{}.nso", name, build_id)); file->Resize(nso.size()); file->WriteBytes(nso); diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp index 61671ea333..22c0f84fcc 100644 --- a/src/core/file_sys/registered_cache.cpp +++ b/src/core/file_sys/registered_cache.cpp @@ -369,7 +369,7 @@ bool PlaceholderCache::Create(const NcaID& id, u64 size) const { if (dir2 == nullptr) return false; - const auto file = dir2->CreateFile(fmt::format("{}.nca", Common::HexToString(id, false))); + const auto file = dir2->CreateAndOpenFile(fmt::format("{}.nca", Common::HexToString(id, false))); if (file == nullptr) return false; @@ -394,7 +394,7 @@ bool PlaceholderCache::Delete(const NcaID& id) const { const auto dir2 = GetOrCreateDirectoryRelative(dir, dirname); - const auto res = dir2->DeleteFile(fmt::format("{}.nca", Common::HexToString(id, false))); + const auto res = dir2->DeleteAndUnlinkFile(fmt::format("{}.nca", Common::HexToString(id, false))); return res; } @@ -932,7 +932,7 @@ bool RegisteredCache::RemoveExistingEntry(u64 title_id) const { const bool isDir = dir->GetDirectoryRelative(path) != nullptr; if (isFile) { - return dir->DeleteFile(path); + return dir->DeleteAndUnlinkFile(path); } else if (isDir) { return dir->DeleteSubdirectoryRecursive(path); } @@ -977,7 +977,7 @@ bool RegisteredCache::RemoveExistingEntry(u64 title_id) const { const auto meta_dir = dir->CreateDirectoryRelative("yuzu_meta"); const auto filename = GetCNMTName(TitleType::Update, title_id + i); if (meta_dir->GetFile(filename)) { - removed_data |= meta_dir->DeleteFile(filename); + removed_data |= meta_dir->DeleteAndUnlinkFile(filename); } } @@ -1019,7 +1019,7 @@ InstallResult RegisteredCache::RawInstallNCA(const NCA& nca, const VfsCopyFuncti LOG_WARNING(Loader, "Overwriting existing NCA..."); VirtualDir c_dir; { c_dir = dir->GetFileRelative(path)->GetContainingDirectory(); } - c_dir->DeleteFile(Common::FS::GetFilename(path)); + c_dir->DeleteAndUnlinkFile(Common::FS::GetFilename(path)); } auto out = dir->CreateFileRelative(path); @@ -1035,7 +1035,7 @@ bool RegisteredCache::RawInstallYuzuMeta(const CNMT& cnmt) { const auto meta_dir = dir->CreateDirectoryRelative("yuzu_meta"); const auto filename = GetCNMTName(cnmt.GetType(), cnmt.GetTitleID()); if (meta_dir->GetFile(filename) == nullptr) { - auto out = meta_dir->CreateFile(filename); + auto out = meta_dir->CreateAndOpenFile(filename); const auto buffer = cnmt.Serialize(); out->Resize(buffer.size()); out->WriteBytes(buffer); diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp index 0ba839ec14..00f87c8b8c 100644 --- a/src/core/file_sys/savedata_factory.cpp +++ b/src/core/file_sys/savedata_factory.cpp @@ -181,7 +181,7 @@ void SaveDataFactory::WriteSaveDataSize(SaveDataType type, u64 title_id, u128 us GetFullPath(program_id, dir, SaveDataSpaceId::User, type, title_id, user_id, 0); const auto relative_dir = GetOrCreateDirectoryRelative(dir, path); - const auto size_file = relative_dir->CreateFile(GetSaveDataSizeFileName()); + const auto size_file = relative_dir->CreateAndOpenFile(GetSaveDataSizeFileName()); if (size_file == nullptr) { return; } diff --git a/src/core/file_sys/vfs/vfs.cpp b/src/core/file_sys/vfs/vfs.cpp index b85b843e3e..cee084eaab 100644 --- a/src/core/file_sys/vfs/vfs.cpp +++ b/src/core/file_sys/vfs/vfs.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project @@ -38,17 +38,17 @@ VfsEntryType VfsFilesystem::GetEntryType(std::string_view path_) const { return VfsEntryType::None; } -VirtualFile VfsFilesystem::OpenFile(std::string_view path_, OpenMode perms) { +VirtualFile VfsFilesystem::OpenFileHandle(std::string_view path_, OpenMode perms) { const auto path = Common::FS::SanitizePath(path_); return root->GetFileRelative(path); } -VirtualFile VfsFilesystem::CreateFile(std::string_view path_, OpenMode perms) { +VirtualFile VfsFilesystem::CreateAndOpenFile(std::string_view path_, OpenMode perms) { const auto path = Common::FS::SanitizePath(path_); return root->CreateFileRelative(path); } -VirtualFile VfsFilesystem::CopyFile(std::string_view old_path_, std::string_view new_path_) { +VirtualFile VfsFilesystem::CopyAndOpenFile(std::string_view old_path_, std::string_view new_path_) { const auto old_path = Common::FS::SanitizePath(old_path_); const auto new_path = Common::FS::SanitizePath(new_path_); @@ -56,17 +56,17 @@ VirtualFile VfsFilesystem::CopyFile(std::string_view old_path_, std::string_view if (Common::FS::GetParentPath(old_path) == Common::FS::GetParentPath(new_path)) { if (!root->Copy(Common::FS::GetFilename(old_path), Common::FS::GetFilename(new_path))) return nullptr; - return OpenFile(new_path, OpenMode::ReadWrite); + return OpenFileHandle(new_path, OpenMode::ReadWrite); } // Do it using RawCopy. Non-default impls are encouraged to optimize this. - const auto old_file = OpenFile(old_path, OpenMode::Read); + const auto old_file = OpenFileHandle(old_path, OpenMode::Read); if (old_file == nullptr) return nullptr; - auto new_file = OpenFile(new_path, OpenMode::Read); + auto new_file = OpenFileHandle(new_path, OpenMode::Read); if (new_file != nullptr) return nullptr; - new_file = CreateFile(new_path, OpenMode::Write); + new_file = CreateAndOpenFile(new_path, OpenMode::Write); if (new_file == nullptr) return nullptr; if (!VfsRawCopy(old_file, new_file)) @@ -74,33 +74,33 @@ VirtualFile VfsFilesystem::CopyFile(std::string_view old_path_, std::string_view return new_file; } -VirtualFile VfsFilesystem::MoveFile(std::string_view old_path, std::string_view new_path) { +VirtualFile VfsFilesystem::MoveAndOpenFile(std::string_view old_path, std::string_view new_path) { const auto sanitized_old_path = Common::FS::SanitizePath(old_path); const auto sanitized_new_path = Common::FS::SanitizePath(new_path); // Again, non-default impls are highly encouraged to provide a more optimized version of this. - auto out = CopyFile(sanitized_old_path, sanitized_new_path); + auto out = CopyAndOpenFile(sanitized_old_path, sanitized_new_path); if (out == nullptr) return nullptr; - if (DeleteFile(sanitized_old_path)) + if (DeleteAndUnlinkFile(sanitized_old_path)) return out; return nullptr; } -bool VfsFilesystem::DeleteFile(std::string_view path_) { +bool VfsFilesystem::DeleteAndUnlinkFile(std::string_view path_) { const auto path = Common::FS::SanitizePath(path_); - auto parent = OpenDirectory(Common::FS::GetParentPath(path), OpenMode::Write); + auto parent = OpenDirectoryHandle(Common::FS::GetParentPath(path), OpenMode::Write); if (parent == nullptr) return false; - return parent->DeleteFile(Common::FS::GetFilename(path)); + return parent->DeleteAndUnlinkFile(Common::FS::GetFilename(path)); } -VirtualDir VfsFilesystem::OpenDirectory(std::string_view path_, OpenMode perms) { +VirtualDir VfsFilesystem::OpenDirectoryHandle(std::string_view path_, OpenMode perms) { const auto path = Common::FS::SanitizePath(path_); return root->GetDirectoryRelative(path); } -VirtualDir VfsFilesystem::CreateDirectory(std::string_view path_, OpenMode perms) { +VirtualDir VfsFilesystem::CreateAndOpenDirectory(std::string_view path_, OpenMode perms) { const auto path = Common::FS::SanitizePath(path_); return root->CreateDirectoryRelative(path); } @@ -110,18 +110,18 @@ VirtualDir VfsFilesystem::CopyDirectory(std::string_view old_path_, std::string_ const auto new_path = Common::FS::SanitizePath(new_path_); // Non-default impls are highly encouraged to provide a more optimized version of this. - auto old_dir = OpenDirectory(old_path, OpenMode::Read); + auto old_dir = OpenDirectoryHandle(old_path, OpenMode::Read); if (old_dir == nullptr) return nullptr; - auto new_dir = OpenDirectory(new_path, OpenMode::Read); + auto new_dir = OpenDirectoryHandle(new_path, OpenMode::Read); if (new_dir != nullptr) return nullptr; - new_dir = CreateDirectory(new_path, OpenMode::Write); + new_dir = CreateAndOpenDirectory(new_path, OpenMode::Write); if (new_dir == nullptr) return nullptr; for (const auto& file : old_dir->GetFiles()) { - const auto x = CopyFile(old_path + '/' + file->GetName(), new_path + '/' + file->GetName()); + const auto x = CopyAndOpenFile(old_path + '/' + file->GetName(), new_path + '/' + file->GetName()); if (x == nullptr) return nullptr; } @@ -151,7 +151,7 @@ VirtualDir VfsFilesystem::MoveDirectory(std::string_view old_path, std::string_v bool VfsFilesystem::DeleteDirectory(std::string_view path_) { const auto path = Common::FS::SanitizePath(path_); - auto parent = OpenDirectory(Common::FS::GetParentPath(path), OpenMode::Write); + auto parent = OpenDirectoryHandle(Common::FS::GetParentPath(path), OpenMode::Write); if (parent == nullptr) return false; return parent->DeleteSubdirectoryRecursive(Common::FS::GetFilename(path)); @@ -306,7 +306,7 @@ VirtualFile VfsDirectory::CreateFileRelative(std::string_view path) { } if (vec.size() == 1) { - return CreateFile(vec[0]); + return CreateAndOpenFile(vec[0]); } auto dir = GetSubdirectory(vec[0]); @@ -365,7 +365,7 @@ bool VfsDirectory::DeleteSubdirectoryRecursive(std::string_view name) { bool success = true; for (const auto& file : dir->GetFiles()) { - if (!DeleteFile(file->GetName())) { + if (!DeleteAndUnlinkFile(file->GetName())) { success = false; } } @@ -387,7 +387,7 @@ bool VfsDirectory::CleanSubdirectoryRecursive(std::string_view name) { bool success = true; for (const auto& file : dir->GetFiles()) { - if (!dir->DeleteFile(file->GetName())) { + if (!dir->DeleteAndUnlinkFile(file->GetName())) { success = false; } } @@ -403,13 +403,13 @@ bool VfsDirectory::CleanSubdirectoryRecursive(std::string_view name) { bool VfsDirectory::Copy(std::string_view src, std::string_view dest) { const auto f1 = GetFile(src); - auto f2 = CreateFile(dest); + auto f2 = CreateAndOpenFile(dest); if (f1 == nullptr || f2 == nullptr) { return false; } if (!f2->Resize(f1->GetSize())) { - DeleteFile(dest); + DeleteAndUnlinkFile(dest); return false; } @@ -444,7 +444,7 @@ VirtualDir ReadOnlyVfsDirectory::CreateSubdirectory(std::string_view name) { return nullptr; } -VirtualFile ReadOnlyVfsDirectory::CreateFile(std::string_view name) { +VirtualFile ReadOnlyVfsDirectory::CreateAndOpenFile(std::string_view name) { return nullptr; } @@ -476,7 +476,7 @@ bool ReadOnlyVfsDirectory::CleanSubdirectoryRecursive(std::string_view name) { return false; } -bool ReadOnlyVfsDirectory::DeleteFile(std::string_view name) { +bool ReadOnlyVfsDirectory::DeleteAndUnlinkFile(std::string_view name) { return false; } @@ -531,7 +531,7 @@ bool VfsRawCopyD(const VirtualDir& src, const VirtualDir& dest, std::size_t bloc return false; for (const auto& file : src->GetFiles()) { - const auto out = dest->CreateFile(file->GetName()); + const auto out = dest->CreateAndOpenFile(file->GetName()); if (!VfsRawCopy(file, out, block_size)) return false; } diff --git a/src/core/file_sys/vfs/vfs.h b/src/core/file_sys/vfs/vfs.h index f846a9669c..17c2d88aeb 100644 --- a/src/core/file_sys/vfs/vfs.h +++ b/src/core/file_sys/vfs/vfs.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -48,22 +51,22 @@ public: virtual VfsEntryType GetEntryType(std::string_view path) const; // Opens the file with path relative to root. If it doesn't exist, returns nullptr. - virtual VirtualFile OpenFile(std::string_view path, OpenMode perms); + virtual VirtualFile OpenFileHandle(std::string_view path, OpenMode perms); // Creates a new, empty file at path - virtual VirtualFile CreateFile(std::string_view path, OpenMode perms); + virtual VirtualFile CreateAndOpenFile(std::string_view path, OpenMode perms); // Copies the file from old_path to new_path, returning the new file on success and nullptr on // failure. - virtual VirtualFile CopyFile(std::string_view old_path, std::string_view new_path); + virtual VirtualFile CopyAndOpenFile(std::string_view old_path, std::string_view new_path); // Moves the file from old_path to new_path, returning the moved file on success and nullptr on // failure. - virtual VirtualFile MoveFile(std::string_view old_path, std::string_view new_path); + virtual VirtualFile MoveAndOpenFile(std::string_view old_path, std::string_view new_path); // Deletes the file with path relative to root, returning true on success. - virtual bool DeleteFile(std::string_view path); + virtual bool DeleteAndUnlinkFile(std::string_view path); // Opens the directory with path relative to root. If it doesn't exist, returns nullptr. - virtual VirtualDir OpenDirectory(std::string_view path, OpenMode perms); + virtual VirtualDir OpenDirectoryHandle(std::string_view path, OpenMode perms); // Creates a new, empty directory at path - virtual VirtualDir CreateDirectory(std::string_view path, OpenMode perms); + virtual VirtualDir CreateAndOpenDirectory(std::string_view path, OpenMode perms); // Copies the directory from old_path to new_path, returning the new directory on success and // nullptr on failure. virtual VirtualDir CopyDirectory(std::string_view old_path, std::string_view new_path); @@ -238,7 +241,7 @@ public: virtual VirtualDir CreateSubdirectory(std::string_view name) = 0; // Creates a new file with name name. Returns a pointer to the new file or nullptr if the // operation failed. - virtual VirtualFile CreateFile(std::string_view name) = 0; + virtual VirtualFile CreateAndOpenFile(std::string_view name) = 0; // Creates a new file at the path relative to this directory. Also creates directories if // they do not exist and is supported by this implementation. Returns nullptr on any failure. @@ -269,7 +272,7 @@ public: virtual bool CleanSubdirectoryRecursive(std::string_view name); // Returns whether or not the file with name name was deleted successfully. - virtual bool DeleteFile(std::string_view name) = 0; + virtual bool DeleteAndUnlinkFile(std::string_view name) = 0; // Returns whether or not this directory was renamed to name. virtual bool Rename(std::string_view name) = 0; @@ -293,7 +296,7 @@ public: bool IsWritable() const override; bool IsReadable() const override; VirtualDir CreateSubdirectory(std::string_view name) override; - VirtualFile CreateFile(std::string_view name) override; + VirtualFile CreateAndOpenFile(std::string_view name) override; VirtualFile CreateFileAbsolute(std::string_view path) override; VirtualFile CreateFileRelative(std::string_view path) override; VirtualDir CreateDirectoryAbsolute(std::string_view path) override; @@ -301,7 +304,7 @@ public: bool DeleteSubdirectory(std::string_view name) override; bool DeleteSubdirectoryRecursive(std::string_view name) override; bool CleanSubdirectoryRecursive(std::string_view name) override; - bool DeleteFile(std::string_view name) override; + bool DeleteAndUnlinkFile(std::string_view name) override; bool Rename(std::string_view name) override; }; diff --git a/src/core/file_sys/vfs/vfs_layered.cpp b/src/core/file_sys/vfs/vfs_layered.cpp index 8dabe03e16..a7b967727e 100644 --- a/src/core/file_sys/vfs/vfs_layered.cpp +++ b/src/core/file_sys/vfs/vfs_layered.cpp @@ -115,7 +115,7 @@ VirtualDir LayeredVfsDirectory::CreateSubdirectory(std::string_view subdir_name) return nullptr; } -VirtualFile LayeredVfsDirectory::CreateFile(std::string_view file_name) { +VirtualFile LayeredVfsDirectory::CreateAndOpenFile(std::string_view file_name) { return nullptr; } @@ -123,7 +123,7 @@ bool LayeredVfsDirectory::DeleteSubdirectory(std::string_view subdir_name) { return false; } -bool LayeredVfsDirectory::DeleteFile(std::string_view file_name) { +bool LayeredVfsDirectory::DeleteAndUnlinkFile(std::string_view file_name) { return false; } diff --git a/src/core/file_sys/vfs/vfs_layered.h b/src/core/file_sys/vfs/vfs_layered.h index 0027ffa9a9..7fc1d0848f 100644 --- a/src/core/file_sys/vfs/vfs_layered.h +++ b/src/core/file_sys/vfs/vfs_layered.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -33,9 +36,9 @@ public: std::string GetName() const override; VirtualDir GetParentDirectory() const override; VirtualDir CreateSubdirectory(std::string_view subdir_name) override; - VirtualFile CreateFile(std::string_view file_name) override; + VirtualFile CreateAndOpenFile(std::string_view file_name) override; bool DeleteSubdirectory(std::string_view subdir_name) override; - bool DeleteFile(std::string_view file_name) override; + bool DeleteAndUnlinkFile(std::string_view file_name) override; bool Rename(std::string_view new_name) override; private: diff --git a/src/core/file_sys/vfs/vfs_real.cpp b/src/core/file_sys/vfs/vfs_real.cpp index 1eafff6c06..05bd456023 100644 --- a/src/core/file_sys/vfs/vfs_real.cpp +++ b/src/core/file_sys/vfs/vfs_real.cpp @@ -106,18 +106,18 @@ VirtualFile RealVfsFilesystem::OpenFileFromEntry(std::string_view path_, std::op return file; } -VirtualFile RealVfsFilesystem::OpenFile(std::string_view path_, OpenMode perms) { +VirtualFile RealVfsFilesystem::OpenFileHandle(std::string_view path_, OpenMode perms) { return OpenFileFromEntry(path_, {}, {}, perms); } -VirtualFile RealVfsFilesystem::CreateFile(std::string_view path_, OpenMode perms) { +VirtualFile RealVfsFilesystem::CreateAndOpenFile(std::string_view path_, OpenMode perms) { const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault); { std::scoped_lock lk{list_lock}; cache.erase(path); } - // Current usages of CreateFile expect to delete the contents of an existing file. + // Current usages of CreateAndOpenFile expect to delete the contents of an existing file. if (FS::IsFile(path)) { FS::IOFile temp{path, FS::FileAccessMode::Write, FS::FileType::BinaryFile}; @@ -127,22 +127,22 @@ VirtualFile RealVfsFilesystem::CreateFile(std::string_view path_, OpenMode perms temp.Close(); - return OpenFile(path, perms); + return OpenFileHandle(path, perms); } if (!FS::NewFile(path)) { return nullptr; } - return OpenFile(path, perms); + return OpenFileHandle(path, perms); } -VirtualFile RealVfsFilesystem::CopyFile(std::string_view old_path_, std::string_view new_path_) { +VirtualFile RealVfsFilesystem::CopyAndOpenFile(std::string_view old_path_, std::string_view new_path_) { // Unused return nullptr; } -VirtualFile RealVfsFilesystem::MoveFile(std::string_view old_path_, std::string_view new_path_) { +VirtualFile RealVfsFilesystem::MoveAndOpenFile(std::string_view old_path_, std::string_view new_path_) { const auto old_path = FS::SanitizePath(old_path_, FS::DirectorySeparator::PlatformDefault); const auto new_path = FS::SanitizePath(new_path_, FS::DirectorySeparator::PlatformDefault); { @@ -153,10 +153,10 @@ VirtualFile RealVfsFilesystem::MoveFile(std::string_view old_path_, std::string_ if (!FS::RenameFile(old_path, new_path)) { return nullptr; } - return OpenFile(new_path, OpenMode::ReadWrite); + return OpenFileHandle(new_path, OpenMode::ReadWrite); } -bool RealVfsFilesystem::DeleteFile(std::string_view path_) { +bool RealVfsFilesystem::DeleteAndUnlinkFile(std::string_view path_) { const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault); { std::scoped_lock lk{list_lock}; @@ -165,12 +165,12 @@ bool RealVfsFilesystem::DeleteFile(std::string_view path_) { return FS::RemoveFile(path); } -VirtualDir RealVfsFilesystem::OpenDirectory(std::string_view path_, OpenMode perms) { +VirtualDir RealVfsFilesystem::OpenDirectoryHandle(std::string_view path_, OpenMode perms) { const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault); return std::shared_ptr(new RealVfsDirectory(*this, path, perms)); } -VirtualDir RealVfsFilesystem::CreateDirectory(std::string_view path_, OpenMode perms) { +VirtualDir RealVfsFilesystem::CreateAndOpenDirectory(std::string_view path_, OpenMode perms) { const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault); if (!FS::CreateDirs(path)) { return nullptr; @@ -192,7 +192,7 @@ VirtualDir RealVfsFilesystem::MoveDirectory(std::string_view old_path_, if (!FS::RenameDir(old_path, new_path)) { return nullptr; } - return OpenDirectory(new_path, OpenMode::ReadWrite); + return OpenDirectoryHandle(new_path, OpenMode::ReadWrite); } bool RealVfsFilesystem::DeleteDirectory(std::string_view path_) { @@ -311,7 +311,7 @@ bool RealVfsFile::Resize(std::size_t new_size) { } VirtualDir RealVfsFile::GetContainingDirectory() const { - return base.OpenDirectory(parent_path, perms); + return base.OpenDirectoryHandle(parent_path, perms); } bool RealVfsFile::IsWritable() const { @@ -340,7 +340,7 @@ std::size_t RealVfsFile::Write(const u8* data, std::size_t length, std::size_t o } bool RealVfsFile::Rename(std::string_view name) { - return base.MoveFile(path, parent_path + '/' + std::string(name)) != nullptr; + return base.MoveAndOpenFile(path, parent_path + '/' + std::string(name)) != nullptr; } // TODO(DarkLordZach): MSVC would not let me combine the following two functions using 'if @@ -380,7 +380,7 @@ std::vector RealVfsDirectory::IterateEntries> GetEntries() const override; diff --git a/src/core/file_sys/vfs/vfs_vector.cpp b/src/core/file_sys/vfs/vfs_vector.cpp index 4d4a90f640..c7c00a8b37 100644 --- a/src/core/file_sys/vfs/vfs_vector.cpp +++ b/src/core/file_sys/vfs/vfs_vector.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project @@ -109,7 +109,7 @@ bool VectorVfsDirectory::DeleteSubdirectory(std::string_view subdir_name) { return FindAndRemoveVectorElement(dirs, subdir_name); } -bool VectorVfsDirectory::DeleteFile(std::string_view file_name) { +bool VectorVfsDirectory::DeleteAndUnlinkFile(std::string_view file_name) { return FindAndRemoveVectorElement(files, file_name); } @@ -122,7 +122,7 @@ VirtualDir VectorVfsDirectory::CreateSubdirectory(std::string_view subdir_name) return nullptr; } -VirtualFile VectorVfsDirectory::CreateFile(std::string_view file_name) { +VirtualFile VectorVfsDirectory::CreateAndOpenFile(std::string_view file_name) { return nullptr; } diff --git a/src/core/file_sys/vfs/vfs_vector.h b/src/core/file_sys/vfs/vfs_vector.h index 86beed931c..073f0b3ba6 100644 --- a/src/core/file_sys/vfs/vfs_vector.h +++ b/src/core/file_sys/vfs/vfs_vector.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project @@ -115,10 +115,10 @@ public: std::string GetName() const override; VirtualDir GetParentDirectory() const override; bool DeleteSubdirectory(std::string_view subdir_name) override; - bool DeleteFile(std::string_view file_name) override; + bool DeleteAndUnlinkFile(std::string_view file_name) override; bool Rename(std::string_view name) override; VirtualDir CreateSubdirectory(std::string_view subdir_name) override; - VirtualFile CreateFile(std::string_view file_name) override; + VirtualFile CreateAndOpenFile(std::string_view file_name) override; virtual void AddFile(VirtualFile file); virtual void AddDirectory(VirtualDir dir); diff --git a/src/core/hle/service/am/frontend/applet_web_browser.cpp b/src/core/hle/service/am/frontend/applet_web_browser.cpp index 92782c58e2..1b3ad12d80 100644 --- a/src/core/hle/service/am/frontend/applet_web_browser.cpp +++ b/src/core/hle/service/am/frontend/applet_web_browser.cpp @@ -216,10 +216,10 @@ void ExtractSharedFonts(Core::System& system) { FileSys::VirtualFile decrypted_font = std::make_shared( std::move(decrypted_data), DECRYPTED_SHARED_FONTS[i]); - const auto temp_dir = system.GetFilesystem()->CreateDirectory( + const auto temp_dir = system.GetFilesystem()->CreateAndOpenDirectory( Common::FS::PathToUTF8String(fonts_dir), FileSys::OpenMode::ReadWrite); - const auto out_file = temp_dir->CreateFile(DECRYPTED_SHARED_FONTS[i]); + const auto out_file = temp_dir->CreateAndOpenFile(DECRYPTED_SHARED_FONTS[i]); FileSys::VfsRawCopy(decrypted_font, out_file); } @@ -362,7 +362,7 @@ void WebBrowser::ExtractOfflineRomFS() { const auto extracted_romfs_dir = FileSys::ExtractRomFS(offline_romfs); - const auto temp_dir = system.GetFilesystem()->CreateDirectory( + const auto temp_dir = system.GetFilesystem()->CreateAndOpenDirectory( Common::FS::PathToUTF8String(offline_cache_dir), FileSys::OpenMode::ReadWrite); FileSys::VfsRawCopyD(extracted_romfs_dir, temp_dir); diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index c192fea454..f0d97be929 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp @@ -52,7 +52,7 @@ std::string VfsDirectoryServiceWrapper::GetName() const { return backing->GetName(); } -Result VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 size) const { +Result VfsDirectoryServiceWrapper::CreateAndOpenFile(const std::string& path_, u64 size) const { std::string path(Common::FS::SanitizePath(path_)); auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path)); if (dir == nullptr) { @@ -64,7 +64,7 @@ Result VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 size return FileSys::ResultPathAlreadyExists; } - auto file = dir->CreateFile(Common::FS::GetFilename(path)); + auto file = dir->CreateAndOpenFile(Common::FS::GetFilename(path)); if (file == nullptr) { // TODO(DarkLordZach): Find a better error code for this return ResultUnknown; @@ -76,7 +76,7 @@ Result VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 size return ResultSuccess; } -Result VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) const { +Result VfsDirectoryServiceWrapper::DeleteAndUnlinkFile(const std::string& path_) const { std::string path(Common::FS::SanitizePath(path_)); if (path.empty()) { // TODO(DarkLordZach): Why do games call this and what should it do? Works as is but... @@ -87,7 +87,7 @@ Result VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) const { if (dir == nullptr || dir->GetFile(Common::FS::GetFilename(path)) == nullptr) { return FileSys::ResultPathNotFound; } - if (!dir->DeleteFile(Common::FS::GetFilename(path))) { + if (!dir->DeleteAndUnlinkFile(Common::FS::GetFilename(path))) { // TODO(DarkLordZach): Find a better error code for this return ResultUnknown; } @@ -95,11 +95,11 @@ Result VfsDirectoryServiceWrapper::DeleteFile(const std::string& path_) const { return ResultSuccess; } -Result VfsDirectoryServiceWrapper::CreateDirectory(const std::string& path_) const { +Result VfsDirectoryServiceWrapper::CreateAndOpenDirectory(const std::string& path_) const { std::string path(Common::FS::SanitizePath(path_)); - // NOTE: This is inaccurate behavior. CreateDirectory is not recursive. - // CreateDirectory should return PathNotFound if the parent directory does not exist. + // NOTE: This is inaccurate behavior. CreateAndOpenDirectory is not recursive. + // CreateAndOpenDirectory should return PathNotFound if the parent directory does not exist. // This is here temporarily in order to have UMM "work" in the meantime. // TODO (Morph): Remove this when a hardware test verifies the correct behavior. const auto components = Common::FS::SplitPathComponents(path); @@ -172,7 +172,7 @@ Result VfsDirectoryServiceWrapper::RenameFile(const std::string& src_path_, } // Move by hand -- TODO(DarkLordZach): Optimize - auto c_res = CreateFile(dest_path, src->GetSize()); + auto c_res = CreateAndOpenFile(dest_path, src->GetSize()); if (c_res != ResultSuccess) return c_res; @@ -182,7 +182,7 @@ Result VfsDirectoryServiceWrapper::RenameFile(const std::string& src_path_, ASSERT_MSG(dest->WriteBytes(src->ReadAllBytes()) == src->GetSize(), "Could not write all of the bytes but everything else has succeeded."); - if (!src->GetContainingDirectory()->DeleteFile(Common::FS::GetFilename(src_path))) { + if (!src->GetContainingDirectory()->DeleteAndUnlinkFile(Common::FS::GetFilename(src_path))) { // TODO(DarkLordZach): Find a better error code for this return ResultUnknown; } @@ -216,7 +216,7 @@ Result VfsDirectoryServiceWrapper::RenameDirectory(const std::string& src_path_, return ResultUnknown; } -Result VfsDirectoryServiceWrapper::OpenFile(FileSys::VirtualFile* out_file, +Result VfsDirectoryServiceWrapper::OpenFileHandle(FileSys::VirtualFile* out_file, const std::string& path_, FileSys::OpenMode mode) const { const std::string path(Common::FS::SanitizePath(path_)); @@ -239,7 +239,7 @@ Result VfsDirectoryServiceWrapper::OpenFile(FileSys::VirtualFile* out_file, return ResultSuccess; } -Result VfsDirectoryServiceWrapper::OpenDirectory(FileSys::VirtualDir* out_directory, +Result VfsDirectoryServiceWrapper::OpenDirectoryHandle(FileSys::VirtualDir* out_directory, const std::string& path_) { std::string path(Common::FS::SanitizePath(path_)); auto dir = GetDirectoryRelativeWrapped(backing, path); @@ -355,7 +355,7 @@ std::shared_ptr FileSystemController::CreateSaveDataFa auto vfs = system.GetFilesystem(); const auto save_directory = - vfs->OpenDirectory(Common::FS::GetEdenPathString(EdenPath::SaveDir), rw_mode); + vfs->OpenDirectoryHandle(Common::FS::GetEdenPathString(EdenPath::SaveDir), rw_mode); return std::make_shared(system, program_id, std::move(save_directory)); } @@ -698,14 +698,14 @@ void FileSystemController::CreateFactories(FileSys::VfsFilesystem& vfs, bool ove const auto rw_mode = FileSys::OpenMode::ReadWrite; auto nand_directory = - vfs.OpenDirectory(Common::FS::GetEdenPathString(EdenPath::NANDDir), rw_mode); - auto sd_directory = vfs.OpenDirectory(Common::FS::PathToUTF8String(sdmc_dir_path), rw_mode); - auto load_directory = vfs.OpenDirectory(Common::FS::GetEdenPathString(EdenPath::LoadDir), + vfs.OpenDirectoryHandle(Common::FS::GetEdenPathString(EdenPath::NANDDir), rw_mode); + auto sd_directory = vfs.OpenDirectoryHandle(Common::FS::PathToUTF8String(sdmc_dir_path), rw_mode); + auto load_directory = vfs.OpenDirectoryHandle(Common::FS::GetEdenPathString(EdenPath::LoadDir), FileSys::OpenMode::Read); - auto sd_load_directory = vfs.OpenDirectory(Common::FS::PathToUTF8String(sdmc_load_dir_path), + auto sd_load_directory = vfs.OpenDirectoryHandle(Common::FS::PathToUTF8String(sdmc_load_dir_path), FileSys::OpenMode::Read); auto dump_directory = - vfs.OpenDirectory(Common::FS::GetEdenPathString(EdenPath::DumpDir), rw_mode); + vfs.OpenDirectoryHandle(Common::FS::GetEdenPathString(EdenPath::DumpDir), rw_mode); if (bis_factory == nullptr) { bis_factory = std::make_unique( @@ -732,7 +732,7 @@ void FileSystemController::CreateFactories(FileSys::VfsFilesystem& vfs, bool ove for (const auto& dir_path : Settings::values.external_content_dirs) { if (!dir_path.empty()) { LOG_DEBUG(Service_FS, "Attempting to open directory: {}", dir_path); - auto dir = vfs.OpenDirectory(dir_path, FileSys::OpenMode::Read); + auto dir = vfs.OpenDirectoryHandle(dir_path, FileSys::OpenMode::Read); if (dir != nullptr) { external_dirs.push_back(std::move(dir)); LOG_DEBUG(Service_FS, "Successfully opened directory: {}", dir_path); diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h index ef45aec627..6b669be9cb 100644 --- a/src/core/hle/service/filesystem/filesystem.h +++ b/src/core/hle/service/filesystem/filesystem.h @@ -174,21 +174,21 @@ public: * @param size The size of the new file, filled with zeroes * @return Result of the operation */ - Result CreateFile(const std::string& path, u64 size) const; + Result CreateAndOpenFile(const std::string& path, u64 size) const; /** * Delete a file specified by its path * @param path Path relative to the archive * @return Result of the operation */ - Result DeleteFile(const std::string& path) const; + Result DeleteAndUnlinkFile(const std::string& path) const; /** * Create a directory specified by its path * @param path Path relative to the archive * @return Result of the operation */ - Result CreateDirectory(const std::string& path) const; + Result CreateAndOpenDirectory(const std::string& path) const; /** * Delete a directory specified by its path @@ -238,7 +238,7 @@ public: * @param mode Mode to open the file with * @return Opened file, or error code */ - Result OpenFile(FileSys::VirtualFile* out_file, const std::string& path, + Result OpenFileHandle(FileSys::VirtualFile* out_file, const std::string& path, FileSys::OpenMode mode) const; /** @@ -246,7 +246,7 @@ public: * @param path Path relative to the archive * @return Opened directory, or error code */ - Result OpenDirectory(FileSys::VirtualDir* out_directory, const std::string& path); + Result OpenDirectoryHandle(FileSys::VirtualDir* out_directory, const std::string& path); /** * Get the type of the specified path diff --git a/src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp b/src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp index 0638111ae9..34bd79fa24 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp +++ b/src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp @@ -18,16 +18,16 @@ IFileSystem::IFileSystem(Core::System& system_, FileSys::VirtualDir dir_, SizeGe dir_)}, size_getter{std::move(size_getter_)} { static const FunctionInfo functions[] = { - {0, D<&IFileSystem::CreateFile>, "CreateFile"}, - {1, D<&IFileSystem::DeleteFile>, "DeleteFile"}, - {2, D<&IFileSystem::CreateDirectory>, "CreateDirectory"}, + {0, D<&IFileSystem::CreateAndOpenFile>, "CreateAndOpenFile"}, + {1, D<&IFileSystem::DeleteAndUnlinkFile>, "DeleteAndUnlinkFile"}, + {2, D<&IFileSystem::CreateAndOpenDirectory>, "CreateAndOpenDirectory"}, {3, D<&IFileSystem::DeleteDirectory>, "DeleteDirectory"}, {4, D<&IFileSystem::DeleteDirectoryRecursively>, "DeleteDirectoryRecursively"}, {5, D<&IFileSystem::RenameFile>, "RenameFile"}, {6, nullptr, "RenameDirectory"}, {7, D<&IFileSystem::GetEntryType>, "GetEntryType"}, - {8, D<&IFileSystem::OpenFile>, "OpenFile"}, - {9, D<&IFileSystem::OpenDirectory>, "OpenDirectory"}, + {8, D<&IFileSystem::OpenFileHandle>, "OpenFileHandle"}, + {9, D<&IFileSystem::OpenDirectoryHandle>, "OpenDirectoryHandle"}, {10, D<&IFileSystem::Commit>, "Commit"}, {11, D<&IFileSystem::GetFreeSpaceSize>, "GetFreeSpaceSize"}, {12, D<&IFileSystem::GetTotalSpaceSize>, "GetTotalSpaceSize"}, @@ -39,24 +39,24 @@ IFileSystem::IFileSystem(Core::System& system_, FileSys::VirtualDir dir_, SizeGe RegisterHandlers(functions); } -Result IFileSystem::CreateFile(const InLargeData path, +Result IFileSystem::CreateAndOpenFile(const InLargeData path, s32 option, s64 size) { LOG_DEBUG(Service_FS, "called. file={}, option={:#X}, size=0x{:08X}", path->str, option, size); - R_RETURN(backend->CreateFile(FileSys::Path(path->str), size)); + R_RETURN(backend->CreateAndOpenFile(FileSys::Path(path->str), size)); } -Result IFileSystem::DeleteFile(const InLargeData path) { +Result IFileSystem::DeleteAndUnlinkFile(const InLargeData path) { LOG_DEBUG(Service_FS, "called. file={}", path->str); - R_RETURN(backend->DeleteFile(FileSys::Path(path->str))); + R_RETURN(backend->DeleteAndUnlinkFile(FileSys::Path(path->str))); } -Result IFileSystem::CreateDirectory( +Result IFileSystem::CreateAndOpenDirectory( const InLargeData path) { LOG_DEBUG(Service_FS, "called. directory={}", path->str); - R_RETURN(backend->CreateDirectory(FileSys::Path(path->str))); + R_RETURN(backend->CreateAndOpenDirectory(FileSys::Path(path->str))); } Result IFileSystem::DeleteDirectory( @@ -88,26 +88,26 @@ Result IFileSystem::RenameFile( R_RETURN(backend->RenameFile(FileSys::Path(old_path->str), FileSys::Path(new_path->str))); } -Result IFileSystem::OpenFile(OutInterface out_interface, +Result IFileSystem::OpenFileHandle(OutInterface out_interface, const InLargeData path, u32 mode) { LOG_DEBUG(Service_FS, "called. file={}, mode={}", path->str, mode); FileSys::VirtualFile vfs_file{}; - R_TRY(backend->OpenFile(&vfs_file, FileSys::Path(path->str), + R_TRY(backend->OpenFileHandle(&vfs_file, FileSys::Path(path->str), static_cast(mode))); *out_interface = std::make_shared(system, vfs_file); R_SUCCEED(); } -Result IFileSystem::OpenDirectory(OutInterface out_interface, +Result IFileSystem::OpenDirectoryHandle(OutInterface out_interface, const InLargeData path, u32 mode) { LOG_DEBUG(Service_FS, "called. directory={}, mode={}", path->str, mode); FileSys::VirtualDir vfs_dir{}; - R_TRY(backend->OpenDirectory(&vfs_dir, FileSys::Path(path->str), + R_TRY(backend->OpenDirectoryHandle(&vfs_dir, FileSys::Path(path->str), static_cast(mode))); *out_interface = std::make_shared(system, vfs_dir, diff --git a/src/core/hle/service/filesystem/fsp/fs_i_filesystem.h b/src/core/hle/service/filesystem/fsp/fs_i_filesystem.h index dd069f36f3..83affb7b47 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_filesystem.h +++ b/src/core/hle/service/filesystem/fsp/fs_i_filesystem.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -25,10 +28,10 @@ class IFileSystem final : public ServiceFramework { public: explicit IFileSystem(Core::System& system_, FileSys::VirtualDir dir_, SizeGetter size_getter_); - Result CreateFile(const InLargeData path, s32 option, + Result CreateAndOpenFile(const InLargeData path, s32 option, s64 size); - Result DeleteFile(const InLargeData path); - Result CreateDirectory(const InLargeData path); + Result DeleteAndUnlinkFile(const InLargeData path); + Result CreateAndOpenDirectory(const InLargeData path); Result DeleteDirectory(const InLargeData path); Result DeleteDirectoryRecursively( const InLargeData path); @@ -36,9 +39,9 @@ public: const InLargeData path); Result RenameFile(const InLargeData old_path, const InLargeData new_path); - Result OpenFile(OutInterface out_interface, + Result OpenFileHandle(OutInterface out_interface, const InLargeData path, u32 mode); - Result OpenDirectory(OutInterface out_interface, + Result OpenDirectoryHandle(OutInterface out_interface, const InLargeData path, u32 mode); Result GetEntryType(Out out_type, diff --git a/src/core/hle/service/mii/mii.cpp b/src/core/hle/service/mii/mii.cpp index 51df5bc628..2d3794ee19 100644 --- a/src/core/hle/service/mii/mii.cpp +++ b/src/core/hle/service/mii/mii.cpp @@ -46,7 +46,7 @@ public: {13, D<&IDatabaseService::AddOrReplace>, "AddOrReplace"}, {14, D<&IDatabaseService::Delete>, "Delete"}, {15, D<&IDatabaseService::DestroyFile>, "DestroyFile"}, - {16, D<&IDatabaseService::DeleteFile>, "DeleteFile"}, + {16, D<&IDatabaseService::DeleteAndUnlinkFile>, "DeleteAndUnlinkFile"}, {17, D<&IDatabaseService::Format>, "Format"}, {18, nullptr, "Import"}, {19, nullptr, "Export"}, @@ -219,7 +219,7 @@ private: R_RETURN(manager->DestroyFile(metadata)); } - Result DeleteFile() { + Result DeleteAndUnlinkFile() { bool is_db_test_mode_enabled{}; m_set_sys->GetSettingsItemValueImpl(is_db_test_mode_enabled, "mii", "is_db_test_mode_enabled"); @@ -227,7 +227,7 @@ private: LOG_INFO(Service_Mii, "called is_db_test_mode_enabled={}", is_db_test_mode_enabled); R_UNLESS(is_db_test_mode_enabled, ResultTestModeOnly); - R_RETURN(manager->DeleteFile()); + R_RETURN(manager->DeleteAndUnlinkFile()); } Result Format() { @@ -336,7 +336,7 @@ public: {15, nullptr, "LoadImage"}, {16, nullptr, "AddOrUpdateImage"}, {17, nullptr, "DeleteImages"}, - {100, nullptr, "DeleteFile"}, + {100, nullptr, "DeleteAndUnlinkFile"}, {101, nullptr, "DestroyFile"}, {102, nullptr, "ImportFile"}, {103, nullptr, "ExportFile"}, diff --git a/src/core/hle/service/mii/mii_database_manager.cpp b/src/core/hle/service/mii/mii_database_manager.cpp index 606df7953d..508f630523 100644 --- a/src/core/hle/service/mii/mii_database_manager.cpp +++ b/src/core/hle/service/mii/mii_database_manager.cpp @@ -372,7 +372,7 @@ Result DatabaseManager::DestroyFile(DatabaseSessionMetadata& metadata) { return result; } -Result DatabaseManager::DeleteFile() { +Result DatabaseManager::DeleteAndUnlinkFile() { const bool result = Common::FS::RemoveFile(system_save_dir / DbFileName); // TODO: Return proper FS error here return result ? ResultSuccess : ResultUnknown; diff --git a/src/core/hle/service/mii/mii_database_manager.h b/src/core/hle/service/mii/mii_database_manager.h index 52c32be82c..d27c295707 100644 --- a/src/core/hle/service/mii/mii_database_manager.h +++ b/src/core/hle/service/mii/mii_database_manager.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -37,7 +40,7 @@ public: Result Append(DatabaseSessionMetadata& metadata, const CharInfo& char_info); Result DestroyFile(DatabaseSessionMetadata& metadata); - Result DeleteFile(); + Result DeleteAndUnlinkFile(); void Format(DatabaseSessionMetadata& metadata); Result SaveDatabase(); diff --git a/src/core/hle/service/mii/mii_manager.cpp b/src/core/hle/service/mii/mii_manager.cpp index ed37830797..b13674da66 100644 --- a/src/core/hle/service/mii/mii_manager.cpp +++ b/src/core/hle/service/mii/mii_manager.cpp @@ -177,8 +177,8 @@ Result MiiManager::DestroyFile(DatabaseSessionMetadata& metadata) { return database_manager.DestroyFile(metadata); } -Result MiiManager::DeleteFile() { - return database_manager.DeleteFile(); +Result MiiManager::DeleteAndUnlinkFile() { + return database_manager.DeleteAndUnlinkFile(); } Result MiiManager::Format(DatabaseSessionMetadata& metadata) { diff --git a/src/core/hle/service/mii/mii_manager.h b/src/core/hle/service/mii/mii_manager.h index 48d8e8bb7d..778fe8dd8d 100644 --- a/src/core/hle/service/mii/mii_manager.h +++ b/src/core/hle/service/mii/mii_manager.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project +// SPDX-License-Identifier: GPL-3.0-or-later + // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later @@ -46,7 +49,7 @@ public: // Test database operations bool IsBrokenWithClearFlag(DatabaseSessionMetadata& metadata); Result DestroyFile(DatabaseSessionMetadata& metadata); - Result DeleteFile(); + Result DeleteAndUnlinkFile(); Result Format(DatabaseSessionMetadata& metadata); // Mii conversions diff --git a/src/dynarmic/src/dynarmic/backend/x64/perf_map.cpp b/src/dynarmic/src/dynarmic/backend/x64/perf_map.cpp index a0b5c4fdde..04ad3dc9e8 100644 --- a/src/dynarmic/src/dynarmic/backend/x64/perf_map.cpp +++ b/src/dynarmic/src/dynarmic/backend/x64/perf_map.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later /* This file is part of the dynarmic project. @@ -26,7 +26,7 @@ namespace { std::mutex mutex; std::FILE* file = nullptr; -void OpenFile() { +void OpenFileHandle() { const char* perf_dir = std::getenv("PERF_BUILDID_DIR"); if (!perf_dir) { file = nullptr; @@ -55,7 +55,7 @@ void PerfMapRegister(const void* start, const void* end, std::string_view friend std::lock_guard guard{mutex}; if (!file) { - OpenFile(); + OpenFileHandle(); if (!file) { return; } @@ -75,7 +75,7 @@ void PerfMapClear() { std::fclose(file); file = nullptr; - OpenFile(); + OpenFileHandle(); } } // namespace Dynarmic::Backend::X64 diff --git a/src/frontend_common/config.h b/src/frontend_common/config.h index 8aaf71cc60..8a95b09e3a 100644 --- a/src/frontend_common/config.h +++ b/src/frontend_common/config.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2023 yuzu Emulator Project @@ -21,11 +21,11 @@ // Workaround for conflicting definition in libloaderapi.h caused by SimpleIni #undef LoadString -#undef CreateFile -#undef DeleteFile -#undef CopyFile -#undef CreateDirectory -#undef MoveFile +#undef CreateAndOpenFile +#undef DeleteAndUnlinkFile +#undef CopyAndOpenFile +#undef CreateAndOpenDirectory +#undef MoveAndOpenFile namespace Core { class System; diff --git a/src/frontend_common/content_manager.h b/src/frontend_common/content_manager.h index 4f3112e3fb..cdc0dd1816 100644 --- a/src/frontend_common/content_manager.h +++ b/src/frontend_common/content_manager.h @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2024 yuzu Emulator Project @@ -162,7 +162,7 @@ inline InstallResult InstallNSP(Core::System& system, FileSys::VfsFilesystem& vf }; std::shared_ptr nsp; - FileSys::VirtualFile file = vfs.OpenFile(filename, FileSys::OpenMode::Read); + FileSys::VirtualFile file = vfs.OpenFileHandle(filename, FileSys::OpenMode::Read); if (boost::to_lower_copy(file->GetName()).ends_with("nsp")) { nsp = std::make_shared(file); if (nsp->IsExtractedType()) { @@ -228,7 +228,7 @@ inline InstallResult InstallNCA(FileSys::VfsFilesystem& vfs, const std::string& }; const auto nca = - std::make_shared(vfs.OpenFile(filename, FileSys::OpenMode::Read)); + std::make_shared(vfs.OpenFileHandle(filename, FileSys::OpenMode::Read)); const auto id = nca->GetStatus(); // Game updates necessary are missing base RomFS @@ -351,7 +351,7 @@ inline GameVerificationResult VerifyGameContents( Core::System& system, const std::string& game_path, const std::function& callback) { const auto loader = Loader::GetLoader( - system, system.GetFilesystem()->OpenFile(game_path, FileSys::OpenMode::Read)); + system, system.GetFilesystem()->OpenFileHandle(game_path, FileSys::OpenMode::Read)); if (loader == nullptr) { return GameVerificationResult::NotImplemented; } diff --git a/src/qt_common/util/content.cpp b/src/qt_common/util/content.cpp index 4d9b324608..6384980c47 100644 --- a/src/qt_common/util/content.cpp +++ b/src/qt_common/util/content.cpp @@ -120,7 +120,7 @@ void InstallFirmware(const QString& location, bool recursive) { for (const auto& firmware_src_path : out) { i++; auto firmware_src_vfile = - vfs->OpenFile(firmware_src_path.generic_string(), FileSys::OpenMode::Read); + vfs->OpenFileHandle(firmware_src_path.generic_string(), FileSys::OpenMode::Read); auto firmware_dst_vfile = firmware_vdir->CreateFileRelative(firmware_src_path.filename().string()); diff --git a/src/qt_common/util/game.cpp b/src/qt_common/util/game.cpp index e037fdae6c..5a6bcfbb1a 100644 --- a/src/qt_common/util/game.cpp +++ b/src/qt_common/util/game.cpp @@ -330,7 +330,7 @@ void RemoveCustomConfiguration(u64 program_id, const std::string& game_path) { void RemoveCacheStorage(u64 program_id) { const auto nand_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::NANDDir); auto vfs_nand_dir = - vfs->OpenDirectory(Common::FS::PathToUTF8String(nand_dir), FileSys::OpenMode::Read); + vfs->OpenDirectoryHandle(Common::FS::PathToUTF8String(nand_dir), FileSys::OpenMode::Read); const auto cache_storage_path = FileSys::SaveDataFactory::GetFullPath( {}, vfs_nand_dir, FileSys::SaveDataSpaceId::User, FileSys::SaveDataType::Cache, @@ -420,7 +420,7 @@ void CreateShortcut(const std::string& game_path, const u64 program_id, QtCommon::system->GetContentProvider()}; const auto control = pm.GetControlMetadata(); const auto loader = Loader::GetLoader( - *QtCommon::system, QtCommon::vfs->OpenFile(game_path, FileSys::OpenMode::Read)); + *QtCommon::system, QtCommon::vfs->OpenFileHandle(game_path, FileSys::OpenMode::Read)); std::string game_title{game_title_}; diff --git a/src/yuzu/game/game_list.cpp b/src/yuzu/game/game_list.cpp index 0e2b6cf7e6..431472d7d5 100644 --- a/src/yuzu/game/game_list.cpp +++ b/src/yuzu/game/game_list.cpp @@ -916,7 +916,7 @@ void GameList::AddPermDirPopup(QMenu& context_menu, QModelIndex selected) { }); connect(open_directory_location, &QAction::triggered, this, [this, game_dir_index] { - emit OpenDirectory( + emit OpenDirectoryHandle( QString::fromStdString(UISettings::values.game_dirs[game_dir_index].path)); }); } diff --git a/src/yuzu/game/game_list.h b/src/yuzu/game/game_list.h index 42efcbdc3b..ba288996a2 100644 --- a/src/yuzu/game/game_list.h +++ b/src/yuzu/game/game_list.h @@ -125,7 +125,7 @@ signals: const CompatibilityList& compatibility_list); void OpenPerGameGeneralRequested(const std::string& file); void LinkToRyujinxRequested(const u64& program_id); - void OpenDirectory(const QString& directory); + void OpenDirectoryHandle(const QString& directory); void AddDirectory(); void ShowList(bool show); void PopulatingCompleted(); diff --git a/src/yuzu/game/game_list_worker.cpp b/src/yuzu/game/game_list_worker.cpp index 777122e135..9faab3bc92 100644 --- a/src/yuzu/game/game_list_worker.cpp +++ b/src/yuzu/game/game_list_worker.cpp @@ -351,7 +351,7 @@ void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_pa if (!is_dir && (HasSupportedFileExtension(physical_name) || IsExtractedNCAMain(physical_name))) { - const auto file = vfs->OpenFile(physical_name, FileSys::OpenMode::Read); + const auto file = vfs->OpenFileHandle(physical_name, FileSys::OpenMode::Read); if (!file) { return true; } diff --git a/src/yuzu/main_window.cpp b/src/yuzu/main_window.cpp index 2e7cef0953..ffeb9f4a10 100644 --- a/src/yuzu/main_window.cpp +++ b/src/yuzu/main_window.cpp @@ -91,16 +91,16 @@ #include "qt_common/util/mod.h" #include "qt_common/util/path.h" -// These are wrappers to avoid the calls to CreateDirectory and CreateFile because of the Windows +// These are wrappers to avoid the calls to CreateAndOpenDirectory and CreateAndOpenFile because of the Windows // defines. static FileSys::VirtualDir VfsFilesystemCreateDirectoryWrapper(const std::string& path, FileSys::OpenMode mode) { - return QtCommon::vfs->CreateDirectory(path, mode); + return QtCommon::vfs->CreateAndOpenDirectory(path, mode); } static FileSys::VirtualFile VfsDirectoryCreateFileWrapper(const FileSys::VirtualDir& dir, const std::string& path) { - return dir->CreateFile(path); + return dir->CreateAndOpenFile(path); } // Frontend // @@ -1557,7 +1557,7 @@ void MainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { void MainWindow::ConnectWidgetEvents() { connect(game_list, &GameList::BootGame, this, &MainWindow::BootGameFromList); connect(game_list, &GameList::GameChosen, this, &MainWindow::OnGameListLoadFile); - connect(game_list, &GameList::OpenDirectory, this, &MainWindow::OnGameListOpenDirectory); + connect(game_list, &GameList::OpenDirectoryHandle, this, &MainWindow::OnGameListOpenDirectory); connect(game_list, &GameList::OpenFolderRequested, this, &MainWindow::OnGameListOpenFolder); connect(game_list, &GameList::OpenTransferableShaderCacheRequested, this, [this](u64 program_id) { QtCommon::Path::OpenShaderCache(program_id, this); }); @@ -2018,7 +2018,7 @@ bool MainWindow::SelectAndSetCurrentUser( void MainWindow::ConfigureFilesystemProvider(const std::string& filepath) { // Ensure all NCAs are registered before launching the game - const auto file = QtCommon::vfs->OpenFile(filepath, FileSys::OpenMode::Read); + const auto file = QtCommon::vfs->OpenFileHandle(filepath, FileSys::OpenMode::Read); if (!file) { return; } @@ -2416,7 +2416,7 @@ void MainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target, case GameListOpenTarget::SaveData: { open_target = tr("Save Data"); const auto save_dir = Common::FS::GetEdenPath(Common::FS::EdenPath::SaveDir); - auto vfs_save_dir = QtCommon::vfs->OpenDirectory(Common::FS::PathToUTF8String(save_dir), + auto vfs_save_dir = QtCommon::vfs->OpenDirectoryHandle(Common::FS::PathToUTF8String(save_dir), FileSys::OpenMode::Read); if (has_user_save) { @@ -2647,7 +2647,7 @@ void MainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pat }; const auto loader = Loader::GetLoader( - *QtCommon::system, QtCommon::vfs->OpenFile(game_path, FileSys::OpenMode::Read)); + *QtCommon::system, QtCommon::vfs->OpenFileHandle(game_path, FileSys::OpenMode::Read)); if (loader == nullptr) { failed(); return;