fix windows vfs shit

This commit is contained in:
lizzie 2026-03-18 03:08:11 +00:00
parent 74f356112e
commit 93fa6d4e38
35 changed files with 217 additions and 196 deletions

View file

@ -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;

View file

@ -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<FileSys::NSP> nsp = std::make_shared<FileSys::NSP>(
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(

View file

@ -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<FileSys::VirtualFile> 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 {

View file

@ -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);

View file

@ -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<int>(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<u32>(mode & OpenMode::ReadWrite) != 0, ResultInvalidOpenMode);
R_UNLESS(static_cast<u32>(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<u64>(mode & OpenDirectoryMode::All) != 0, ResultInvalidOpenMode);
R_UNLESS(static_cast<u64>(
@ -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() {

View file

@ -403,7 +403,7 @@ std::vector<u8> PatchManager::PatchNSO(const std::vector<u8>& 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);

View file

@ -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);

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
};

View file

@ -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;
}

View file

@ -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:

View file

@ -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<RealVfsDirectory>(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<VirtualDir> RealVfsDirectory::IterateEntries<RealVfsDirectory, VfsDi
&out](const std::filesystem::directory_entry& entry) {
const auto full_path_string = FS::PathToUTF8String(entry.path());
out.emplace_back(base.OpenDirectory(full_path_string, perms));
out.emplace_back(base.OpenDirectoryHandle(full_path_string, perms));
return true;
};
@ -406,7 +406,7 @@ VirtualFile RealVfsDirectory::GetFileRelative(std::string_view relative_path) co
if (!FS::Exists(full_path) || FS::IsDir(full_path)) {
return nullptr;
}
return base.OpenFile(full_path, perms);
return base.OpenFileHandle(full_path, perms);
}
VirtualDir RealVfsDirectory::GetDirectoryRelative(std::string_view relative_path) const {
@ -414,7 +414,7 @@ VirtualDir RealVfsDirectory::GetDirectoryRelative(std::string_view relative_path
if (!FS::Exists(full_path) || !FS::IsDir(full_path)) {
return nullptr;
}
return base.OpenDirectory(full_path, perms);
return base.OpenDirectoryHandle(full_path, perms);
}
VirtualFile RealVfsDirectory::GetFile(std::string_view name) const {
@ -430,12 +430,12 @@ VirtualFile RealVfsDirectory::CreateFileRelative(std::string_view relative_path)
if (!FS::CreateParentDirs(full_path)) {
return nullptr;
}
return base.CreateFile(full_path, perms);
return base.CreateAndOpenFile(full_path, perms);
}
VirtualDir RealVfsDirectory::CreateDirectoryRelative(std::string_view relative_path) {
const auto full_path = FS::SanitizePath(path + '/' + std::string(relative_path));
return base.CreateDirectory(full_path, perms);
return base.CreateAndOpenDirectory(full_path, perms);
}
bool RealVfsDirectory::DeleteSubdirectoryRecursive(std::string_view name) {
@ -491,17 +491,17 @@ VirtualDir RealVfsDirectory::GetParentDirectory() const {
return nullptr;
}
return base.OpenDirectory(parent_path, perms);
return base.OpenDirectoryHandle(parent_path, perms);
}
VirtualDir RealVfsDirectory::CreateSubdirectory(std::string_view name) {
const std::string subdir_path = (path + '/').append(name);
return base.CreateDirectory(subdir_path, perms);
return base.CreateAndOpenDirectory(subdir_path, perms);
}
VirtualFile RealVfsDirectory::CreateFile(std::string_view name) {
VirtualFile RealVfsDirectory::CreateAndOpenFile(std::string_view name) {
const std::string file_path = (path + '/').append(name);
return base.CreateFile(file_path, perms);
return base.CreateAndOpenFile(file_path, perms);
}
bool RealVfsDirectory::DeleteSubdirectory(std::string_view name) {
@ -509,14 +509,14 @@ bool RealVfsDirectory::DeleteSubdirectory(std::string_view name) {
return base.DeleteDirectory(subdir_path);
}
bool RealVfsDirectory::DeleteFile(std::string_view name) {
bool RealVfsDirectory::DeleteAndUnlinkFile(std::string_view name) {
const std::string file_path = (path + '/').append(name);
return base.DeleteFile(file_path);
return base.DeleteAndUnlinkFile(file_path);
}
bool RealVfsDirectory::Rename(std::string_view name) {
const std::string new_name = (parent_path + '/').append(name);
return base.MoveFile(path, new_name) != nullptr;
return base.MoveAndOpenFile(path, new_name) != nullptr;
}
std::string RealVfsDirectory::GetFullPath() const {

View file

@ -36,13 +36,13 @@ public:
bool IsReadable() const override;
bool IsWritable() const override;
VfsEntryType GetEntryType(std::string_view path) const override;
VirtualFile OpenFile(std::string_view path, OpenMode perms = OpenMode::Read) override;
VirtualFile CreateFile(std::string_view path, OpenMode perms = OpenMode::ReadWrite) override;
VirtualFile CopyFile(std::string_view old_path, std::string_view new_path) override;
VirtualFile MoveFile(std::string_view old_path, std::string_view new_path) override;
bool DeleteFile(std::string_view path) override;
VirtualDir OpenDirectory(std::string_view path, OpenMode perms = OpenMode::Read) override;
VirtualDir CreateDirectory(std::string_view path,
VirtualFile OpenFileHandle(std::string_view path, OpenMode perms = OpenMode::Read) override;
VirtualFile CreateAndOpenFile(std::string_view path, OpenMode perms = OpenMode::ReadWrite) override;
VirtualFile CopyAndOpenFile(std::string_view old_path, std::string_view new_path) override;
VirtualFile MoveAndOpenFile(std::string_view old_path, std::string_view new_path) override;
bool DeleteAndUnlinkFile(std::string_view path) override;
VirtualDir OpenDirectoryHandle(std::string_view path, OpenMode perms = OpenMode::Read) override;
VirtualDir CreateAndOpenDirectory(std::string_view path,
OpenMode perms = OpenMode::ReadWrite) override;
VirtualDir CopyDirectory(std::string_view old_path, std::string_view new_path) override;
VirtualDir MoveDirectory(std::string_view old_path, std::string_view new_path) override;
@ -130,9 +130,9 @@ public:
std::string GetName() const override;
VirtualDir GetParentDirectory() const override;
VirtualDir CreateSubdirectory(std::string_view name) override;
VirtualFile CreateFile(std::string_view name) override;
VirtualFile CreateAndOpenFile(std::string_view name) override;
bool DeleteSubdirectory(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;
std::string GetFullPath() const override;
std::map<std::string, VfsEntryType, std::less<>> GetEntries() const override;

View file

@ -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;
}

View file

@ -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);

View file

@ -216,10 +216,10 @@ void ExtractSharedFonts(Core::System& system) {
FileSys::VirtualFile decrypted_font = std::make_shared<FileSys::VectorVfsFile>(
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);

View file

@ -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<FileSys::SaveDataFactory> 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<FileSys::SaveDataFactory>(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<FileSys::BISFactory>(
@ -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);

View file

@ -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

View file

@ -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<FileSys::Sf::Path, BufferAttr_HipcPointer> path,
Result IFileSystem::CreateAndOpenFile(const InLargeData<FileSys::Sf::Path, BufferAttr_HipcPointer> 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<FileSys::Sf::Path, BufferAttr_HipcPointer> path) {
Result IFileSystem::DeleteAndUnlinkFile(const InLargeData<FileSys::Sf::Path, BufferAttr_HipcPointer> 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<FileSys::Sf::Path, BufferAttr_HipcPointer> 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<IFile> out_interface,
Result IFileSystem::OpenFileHandle(OutInterface<IFile> out_interface,
const InLargeData<FileSys::Sf::Path, BufferAttr_HipcPointer> 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<FileSys::OpenMode>(mode)));
*out_interface = std::make_shared<IFile>(system, vfs_file);
R_SUCCEED();
}
Result IFileSystem::OpenDirectory(OutInterface<IDirectory> out_interface,
Result IFileSystem::OpenDirectoryHandle(OutInterface<IDirectory> out_interface,
const InLargeData<FileSys::Sf::Path, BufferAttr_HipcPointer> 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<FileSys::OpenDirectoryMode>(mode)));
*out_interface = std::make_shared<IDirectory>(system, vfs_dir,

View file

@ -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<IFileSystem> {
public:
explicit IFileSystem(Core::System& system_, FileSys::VirtualDir dir_, SizeGetter size_getter_);
Result CreateFile(const InLargeData<FileSys::Sf::Path, BufferAttr_HipcPointer> path, s32 option,
Result CreateAndOpenFile(const InLargeData<FileSys::Sf::Path, BufferAttr_HipcPointer> path, s32 option,
s64 size);
Result DeleteFile(const InLargeData<FileSys::Sf::Path, BufferAttr_HipcPointer> path);
Result CreateDirectory(const InLargeData<FileSys::Sf::Path, BufferAttr_HipcPointer> path);
Result DeleteAndUnlinkFile(const InLargeData<FileSys::Sf::Path, BufferAttr_HipcPointer> path);
Result CreateAndOpenDirectory(const InLargeData<FileSys::Sf::Path, BufferAttr_HipcPointer> path);
Result DeleteDirectory(const InLargeData<FileSys::Sf::Path, BufferAttr_HipcPointer> path);
Result DeleteDirectoryRecursively(
const InLargeData<FileSys::Sf::Path, BufferAttr_HipcPointer> path);
@ -36,9 +39,9 @@ public:
const InLargeData<FileSys::Sf::Path, BufferAttr_HipcPointer> path);
Result RenameFile(const InLargeData<FileSys::Sf::Path, BufferAttr_HipcPointer> old_path,
const InLargeData<FileSys::Sf::Path, BufferAttr_HipcPointer> new_path);
Result OpenFile(OutInterface<IFile> out_interface,
Result OpenFileHandle(OutInterface<IFile> out_interface,
const InLargeData<FileSys::Sf::Path, BufferAttr_HipcPointer> path, u32 mode);
Result OpenDirectory(OutInterface<IDirectory> out_interface,
Result OpenDirectoryHandle(OutInterface<IDirectory> out_interface,
const InLargeData<FileSys::Sf::Path, BufferAttr_HipcPointer> path,
u32 mode);
Result GetEntryType(Out<u32> out_type,

View file

@ -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"},

View file

@ -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;

View file

@ -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();

View file

@ -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) {

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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<FileSys::NSP> 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<FileSys::NSP>(file);
if (nsp->IsExtractedType()) {
@ -228,7 +228,7 @@ inline InstallResult InstallNCA(FileSys::VfsFilesystem& vfs, const std::string&
};
const auto nca =
std::make_shared<FileSys::NCA>(vfs.OpenFile(filename, FileSys::OpenMode::Read));
std::make_shared<FileSys::NCA>(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<bool(size_t, size_t)>& 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;
}

View file

@ -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());

View file

@ -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_};

View file

@ -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));
});
}

View file

@ -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();

View file

@ -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;
}

View file

@ -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;