diff options
Diffstat (limited to 'src')
21 files changed, 195 insertions, 188 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 8f9dd5efa..1b412ac98 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -21,7 +21,7 @@ | |||
| 21 | #include "core/debugger/debugger.h" | 21 | #include "core/debugger/debugger.h" |
| 22 | #include "core/device_memory.h" | 22 | #include "core/device_memory.h" |
| 23 | #include "core/file_sys/bis_factory.h" | 23 | #include "core/file_sys/bis_factory.h" |
| 24 | #include "core/file_sys/mode.h" | 24 | #include "core/file_sys/fs_filesystem.h" |
| 25 | #include "core/file_sys/patch_manager.h" | 25 | #include "core/file_sys/patch_manager.h" |
| 26 | #include "core/file_sys/registered_cache.h" | 26 | #include "core/file_sys/registered_cache.h" |
| 27 | #include "core/file_sys/romfs_factory.h" | 27 | #include "core/file_sys/romfs_factory.h" |
| @@ -102,7 +102,7 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, | |||
| 102 | Common::SplitPath(path, &dir_name, &filename, nullptr); | 102 | Common::SplitPath(path, &dir_name, &filename, nullptr); |
| 103 | 103 | ||
| 104 | if (filename == "00") { | 104 | if (filename == "00") { |
| 105 | const auto dir = vfs->OpenDirectory(dir_name, FileSys::Mode::Read); | 105 | const auto dir = vfs->OpenDirectory(dir_name, FileSys::OpenMode::Read); |
| 106 | std::vector<FileSys::VirtualFile> concat; | 106 | std::vector<FileSys::VirtualFile> concat; |
| 107 | 107 | ||
| 108 | for (u32 i = 0; i < 0x10; ++i) { | 108 | for (u32 i = 0; i < 0x10; ++i) { |
| @@ -127,10 +127,10 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, | |||
| 127 | } | 127 | } |
| 128 | 128 | ||
| 129 | if (Common::FS::IsDir(path)) { | 129 | if (Common::FS::IsDir(path)) { |
| 130 | return vfs->OpenFile(path + "/main", FileSys::Mode::Read); | 130 | return vfs->OpenFile(path + "/main", FileSys::OpenMode::Read); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | return vfs->OpenFile(path, FileSys::Mode::Read); | 133 | return vfs->OpenFile(path, FileSys::OpenMode::Read); |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | struct System::Impl { | 136 | struct System::Impl { |
diff --git a/src/core/file_sys/bis_factory.cpp b/src/core/file_sys/bis_factory.cpp index f275f5fe4..db667438e 100644 --- a/src/core/file_sys/bis_factory.cpp +++ b/src/core/file_sys/bis_factory.cpp | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | #include <fmt/format.h> | 4 | #include <fmt/format.h> |
| 5 | #include "common/fs/path_util.h" | 5 | #include "common/fs/path_util.h" |
| 6 | #include "core/file_sys/bis_factory.h" | 6 | #include "core/file_sys/bis_factory.h" |
| 7 | #include "core/file_sys/mode.h" | ||
| 8 | #include "core/file_sys/registered_cache.h" | 7 | #include "core/file_sys/registered_cache.h" |
| 9 | #include "core/file_sys/vfs/vfs.h" | 8 | #include "core/file_sys/vfs/vfs.h" |
| 10 | 9 | ||
| @@ -84,7 +83,7 @@ VirtualFile BISFactory::OpenPartitionStorage(BisPartitionId id, | |||
| 84 | VirtualFilesystem file_system) const { | 83 | VirtualFilesystem file_system) const { |
| 85 | auto& keys = Core::Crypto::KeyManager::Instance(); | 84 | auto& keys = Core::Crypto::KeyManager::Instance(); |
| 86 | Core::Crypto::PartitionDataManager pdm{file_system->OpenDirectory( | 85 | Core::Crypto::PartitionDataManager pdm{file_system->OpenDirectory( |
| 87 | Common::FS::GetYuzuPathString(Common::FS::YuzuPath::NANDDir), Mode::Read)}; | 86 | Common::FS::GetYuzuPathString(Common::FS::YuzuPath::NANDDir), OpenMode::Read)}; |
| 88 | keys.PopulateFromPartitionData(pdm); | 87 | keys.PopulateFromPartitionData(pdm); |
| 89 | 88 | ||
| 90 | switch (id) { | 89 | switch (id) { |
diff --git a/src/core/file_sys/directory.h b/src/core/file_sys/directory.h deleted file mode 100644 index a853c00f3..000000000 --- a/src/core/file_sys/directory.h +++ /dev/null | |||
| @@ -1,39 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <cstddef> | ||
| 7 | #include "common/common_funcs.h" | ||
| 8 | #include "common/common_types.h" | ||
| 9 | |||
| 10 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 11 | // FileSys namespace | ||
| 12 | |||
| 13 | namespace FileSys { | ||
| 14 | |||
| 15 | enum class EntryType : u8 { | ||
| 16 | Directory = 0, | ||
| 17 | File = 1, | ||
| 18 | }; | ||
| 19 | |||
| 20 | // Structure of a directory entry, from | ||
| 21 | // http://switchbrew.org/index.php?title=Filesystem_services#DirectoryEntry | ||
| 22 | struct Entry { | ||
| 23 | Entry(std::string_view view, EntryType entry_type, u64 entry_size) | ||
| 24 | : type{entry_type}, file_size{entry_size} { | ||
| 25 | const std::size_t copy_size = view.copy(filename, std::size(filename) - 1); | ||
| 26 | filename[copy_size] = '\0'; | ||
| 27 | } | ||
| 28 | |||
| 29 | char filename[0x301]; | ||
| 30 | INSERT_PADDING_BYTES(3); | ||
| 31 | EntryType type; | ||
| 32 | INSERT_PADDING_BYTES(3); | ||
| 33 | u64 file_size; | ||
| 34 | }; | ||
| 35 | static_assert(sizeof(Entry) == 0x310, "Directory Entry struct isn't exactly 0x310 bytes long!"); | ||
| 36 | static_assert(offsetof(Entry, type) == 0x304, "Wrong offset for type in Entry."); | ||
| 37 | static_assert(offsetof(Entry, file_size) == 0x308, "Wrong offset for file_size in Entry."); | ||
| 38 | |||
| 39 | } // namespace FileSys | ||
diff --git a/src/core/file_sys/fs_directory.h b/src/core/file_sys/fs_directory.h new file mode 100644 index 000000000..cba6155f8 --- /dev/null +++ b/src/core/file_sys/fs_directory.h | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | namespace FileSys { | ||
| 7 | |||
| 8 | constexpr inline size_t EntryNameLengthMax = 0x300; | ||
| 9 | |||
| 10 | struct DirectoryEntry { | ||
| 11 | DirectoryEntry(std::string_view view, s8 entry_type, u64 entry_size) | ||
| 12 | : type{entry_type}, file_size{static_cast<s64>(entry_size)} { | ||
| 13 | const std::size_t copy_size = view.copy(name, std::size(name) - 1); | ||
| 14 | name[copy_size] = '\0'; | ||
| 15 | } | ||
| 16 | |||
| 17 | char name[EntryNameLengthMax + 1]; | ||
| 18 | INSERT_PADDING_BYTES(3); | ||
| 19 | s8 type; | ||
| 20 | INSERT_PADDING_BYTES(3); | ||
| 21 | s64 file_size; | ||
| 22 | }; | ||
| 23 | |||
| 24 | static_assert(sizeof(DirectoryEntry) == 0x310, | ||
| 25 | "Directory Entry struct isn't exactly 0x310 bytes long!"); | ||
| 26 | static_assert(offsetof(DirectoryEntry, type) == 0x304, "Wrong offset for type in Entry."); | ||
| 27 | static_assert(offsetof(DirectoryEntry, file_size) == 0x308, "Wrong offset for file_size in Entry."); | ||
| 28 | |||
| 29 | struct DirectoryHandle { | ||
| 30 | void* handle; | ||
| 31 | }; | ||
| 32 | |||
| 33 | } // namespace FileSys | ||
diff --git a/src/core/file_sys/fs_filesystem.h b/src/core/file_sys/fs_filesystem.h new file mode 100644 index 000000000..436d6c731 --- /dev/null +++ b/src/core/file_sys/fs_filesystem.h | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | namespace FileSys { | ||
| 7 | |||
| 8 | enum class OpenMode : u32 { | ||
| 9 | Read = (1 << 0), | ||
| 10 | Write = (1 << 1), | ||
| 11 | AllowAppend = (1 << 2), | ||
| 12 | |||
| 13 | ReadWrite = (Read | Write), | ||
| 14 | All = (ReadWrite | AllowAppend), | ||
| 15 | }; | ||
| 16 | DECLARE_ENUM_FLAG_OPERATORS(OpenMode) | ||
| 17 | |||
| 18 | enum class OpenDirectoryMode : u64 { | ||
| 19 | Directory = (1 << 0), | ||
| 20 | File = (1 << 1), | ||
| 21 | |||
| 22 | All = (Directory | File), | ||
| 23 | |||
| 24 | /* TODO: Separate enum, like N? */ | ||
| 25 | _NotRequireFileSize = (1 << 31), | ||
| 26 | }; | ||
| 27 | DECLARE_ENUM_FLAG_OPERATORS(OpenDirectoryMode) | ||
| 28 | |||
| 29 | enum class DirectoryEntryType : u8 { | ||
| 30 | Directory = 0, | ||
| 31 | File = 1, | ||
| 32 | }; | ||
| 33 | |||
| 34 | enum class CreateOption : u8 { | ||
| 35 | None = (0 << 0), | ||
| 36 | BigFile = (1 << 0), | ||
| 37 | }; | ||
| 38 | |||
| 39 | } // namespace FileSys | ||
diff --git a/src/core/file_sys/mode.h b/src/core/file_sys/mode.h deleted file mode 100644 index 9596ef4fd..000000000 --- a/src/core/file_sys/mode.h +++ /dev/null | |||
| @@ -1,23 +0,0 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "common/common_funcs.h" | ||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 9 | namespace FileSys { | ||
| 10 | |||
| 11 | enum class Mode : u32 { | ||
| 12 | Read = 1 << 0, | ||
| 13 | Write = 1 << 1, | ||
| 14 | ReadWrite = Read | Write, | ||
| 15 | Append = 1 << 2, | ||
| 16 | ReadAppend = Read | Append, | ||
| 17 | WriteAppend = Write | Append, | ||
| 18 | All = ReadWrite | Append, | ||
| 19 | }; | ||
| 20 | |||
| 21 | DECLARE_ENUM_FLAG_OPERATORS(Mode) | ||
| 22 | |||
| 23 | } // namespace FileSys | ||
diff --git a/src/core/file_sys/vfs/vfs.cpp b/src/core/file_sys/vfs/vfs.cpp index b88a5f91d..a04292760 100644 --- a/src/core/file_sys/vfs/vfs.cpp +++ b/src/core/file_sys/vfs/vfs.cpp | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | #include <numeric> | 5 | #include <numeric> |
| 6 | #include <string> | 6 | #include <string> |
| 7 | #include "common/fs/path_util.h" | 7 | #include "common/fs/path_util.h" |
| 8 | #include "core/file_sys/mode.h" | ||
| 9 | #include "core/file_sys/vfs/vfs.h" | 8 | #include "core/file_sys/vfs/vfs.h" |
| 10 | 9 | ||
| 11 | namespace FileSys { | 10 | namespace FileSys { |
| @@ -36,12 +35,12 @@ VfsEntryType VfsFilesystem::GetEntryType(std::string_view path_) const { | |||
| 36 | return VfsEntryType::None; | 35 | return VfsEntryType::None; |
| 37 | } | 36 | } |
| 38 | 37 | ||
| 39 | VirtualFile VfsFilesystem::OpenFile(std::string_view path_, Mode perms) { | 38 | VirtualFile VfsFilesystem::OpenFile(std::string_view path_, OpenMode perms) { |
| 40 | const auto path = Common::FS::SanitizePath(path_); | 39 | const auto path = Common::FS::SanitizePath(path_); |
| 41 | return root->GetFileRelative(path); | 40 | return root->GetFileRelative(path); |
| 42 | } | 41 | } |
| 43 | 42 | ||
| 44 | VirtualFile VfsFilesystem::CreateFile(std::string_view path_, Mode perms) { | 43 | VirtualFile VfsFilesystem::CreateFile(std::string_view path_, OpenMode perms) { |
| 45 | const auto path = Common::FS::SanitizePath(path_); | 44 | const auto path = Common::FS::SanitizePath(path_); |
| 46 | return root->CreateFileRelative(path); | 45 | return root->CreateFileRelative(path); |
| 47 | } | 46 | } |
| @@ -54,17 +53,17 @@ VirtualFile VfsFilesystem::CopyFile(std::string_view old_path_, std::string_view | |||
| 54 | if (Common::FS::GetParentPath(old_path) == Common::FS::GetParentPath(new_path)) { | 53 | if (Common::FS::GetParentPath(old_path) == Common::FS::GetParentPath(new_path)) { |
| 55 | if (!root->Copy(Common::FS::GetFilename(old_path), Common::FS::GetFilename(new_path))) | 54 | if (!root->Copy(Common::FS::GetFilename(old_path), Common::FS::GetFilename(new_path))) |
| 56 | return nullptr; | 55 | return nullptr; |
| 57 | return OpenFile(new_path, Mode::ReadWrite); | 56 | return OpenFile(new_path, OpenMode::ReadWrite); |
| 58 | } | 57 | } |
| 59 | 58 | ||
| 60 | // Do it using RawCopy. Non-default impls are encouraged to optimize this. | 59 | // Do it using RawCopy. Non-default impls are encouraged to optimize this. |
| 61 | const auto old_file = OpenFile(old_path, Mode::Read); | 60 | const auto old_file = OpenFile(old_path, OpenMode::Read); |
| 62 | if (old_file == nullptr) | 61 | if (old_file == nullptr) |
| 63 | return nullptr; | 62 | return nullptr; |
| 64 | auto new_file = OpenFile(new_path, Mode::Read); | 63 | auto new_file = OpenFile(new_path, OpenMode::Read); |
| 65 | if (new_file != nullptr) | 64 | if (new_file != nullptr) |
| 66 | return nullptr; | 65 | return nullptr; |
| 67 | new_file = CreateFile(new_path, Mode::Write); | 66 | new_file = CreateFile(new_path, OpenMode::Write); |
| 68 | if (new_file == nullptr) | 67 | if (new_file == nullptr) |
| 69 | return nullptr; | 68 | return nullptr; |
| 70 | if (!VfsRawCopy(old_file, new_file)) | 69 | if (!VfsRawCopy(old_file, new_file)) |
| @@ -87,18 +86,18 @@ VirtualFile VfsFilesystem::MoveFile(std::string_view old_path, std::string_view | |||
| 87 | 86 | ||
| 88 | bool VfsFilesystem::DeleteFile(std::string_view path_) { | 87 | bool VfsFilesystem::DeleteFile(std::string_view path_) { |
| 89 | const auto path = Common::FS::SanitizePath(path_); | 88 | const auto path = Common::FS::SanitizePath(path_); |
| 90 | auto parent = OpenDirectory(Common::FS::GetParentPath(path), Mode::Write); | 89 | auto parent = OpenDirectory(Common::FS::GetParentPath(path), OpenMode::Write); |
| 91 | if (parent == nullptr) | 90 | if (parent == nullptr) |
| 92 | return false; | 91 | return false; |
| 93 | return parent->DeleteFile(Common::FS::GetFilename(path)); | 92 | return parent->DeleteFile(Common::FS::GetFilename(path)); |
| 94 | } | 93 | } |
| 95 | 94 | ||
| 96 | VirtualDir VfsFilesystem::OpenDirectory(std::string_view path_, Mode perms) { | 95 | VirtualDir VfsFilesystem::OpenDirectory(std::string_view path_, OpenMode perms) { |
| 97 | const auto path = Common::FS::SanitizePath(path_); | 96 | const auto path = Common::FS::SanitizePath(path_); |
| 98 | return root->GetDirectoryRelative(path); | 97 | return root->GetDirectoryRelative(path); |
| 99 | } | 98 | } |
| 100 | 99 | ||
| 101 | VirtualDir VfsFilesystem::CreateDirectory(std::string_view path_, Mode perms) { | 100 | VirtualDir VfsFilesystem::CreateDirectory(std::string_view path_, OpenMode perms) { |
| 102 | const auto path = Common::FS::SanitizePath(path_); | 101 | const auto path = Common::FS::SanitizePath(path_); |
| 103 | return root->CreateDirectoryRelative(path); | 102 | return root->CreateDirectoryRelative(path); |
| 104 | } | 103 | } |
| @@ -108,13 +107,13 @@ VirtualDir VfsFilesystem::CopyDirectory(std::string_view old_path_, std::string_ | |||
| 108 | const auto new_path = Common::FS::SanitizePath(new_path_); | 107 | const auto new_path = Common::FS::SanitizePath(new_path_); |
| 109 | 108 | ||
| 110 | // Non-default impls are highly encouraged to provide a more optimized version of this. | 109 | // Non-default impls are highly encouraged to provide a more optimized version of this. |
| 111 | auto old_dir = OpenDirectory(old_path, Mode::Read); | 110 | auto old_dir = OpenDirectory(old_path, OpenMode::Read); |
| 112 | if (old_dir == nullptr) | 111 | if (old_dir == nullptr) |
| 113 | return nullptr; | 112 | return nullptr; |
| 114 | auto new_dir = OpenDirectory(new_path, Mode::Read); | 113 | auto new_dir = OpenDirectory(new_path, OpenMode::Read); |
| 115 | if (new_dir != nullptr) | 114 | if (new_dir != nullptr) |
| 116 | return nullptr; | 115 | return nullptr; |
| 117 | new_dir = CreateDirectory(new_path, Mode::Write); | 116 | new_dir = CreateDirectory(new_path, OpenMode::Write); |
| 118 | if (new_dir == nullptr) | 117 | if (new_dir == nullptr) |
| 119 | return nullptr; | 118 | return nullptr; |
| 120 | 119 | ||
| @@ -149,7 +148,7 @@ VirtualDir VfsFilesystem::MoveDirectory(std::string_view old_path, std::string_v | |||
| 149 | 148 | ||
| 150 | bool VfsFilesystem::DeleteDirectory(std::string_view path_) { | 149 | bool VfsFilesystem::DeleteDirectory(std::string_view path_) { |
| 151 | const auto path = Common::FS::SanitizePath(path_); | 150 | const auto path = Common::FS::SanitizePath(path_); |
| 152 | auto parent = OpenDirectory(Common::FS::GetParentPath(path), Mode::Write); | 151 | auto parent = OpenDirectory(Common::FS::GetParentPath(path), OpenMode::Write); |
| 153 | if (parent == nullptr) | 152 | if (parent == nullptr) |
| 154 | return false; | 153 | return false; |
| 155 | return parent->DeleteSubdirectoryRecursive(Common::FS::GetFilename(path)); | 154 | return parent->DeleteSubdirectoryRecursive(Common::FS::GetFilename(path)); |
diff --git a/src/core/file_sys/vfs/vfs.h b/src/core/file_sys/vfs/vfs.h index 6830244e3..f846a9669 100644 --- a/src/core/file_sys/vfs/vfs.h +++ b/src/core/file_sys/vfs/vfs.h | |||
| @@ -13,12 +13,11 @@ | |||
| 13 | 13 | ||
| 14 | #include "common/common_funcs.h" | 14 | #include "common/common_funcs.h" |
| 15 | #include "common/common_types.h" | 15 | #include "common/common_types.h" |
| 16 | #include "core/file_sys/fs_filesystem.h" | ||
| 16 | #include "core/file_sys/vfs/vfs_types.h" | 17 | #include "core/file_sys/vfs/vfs_types.h" |
| 17 | 18 | ||
| 18 | namespace FileSys { | 19 | namespace FileSys { |
| 19 | 20 | ||
| 20 | enum class Mode : u32; | ||
| 21 | |||
| 22 | // An enumeration representing what can be at the end of a path in a VfsFilesystem | 21 | // An enumeration representing what can be at the end of a path in a VfsFilesystem |
| 23 | enum class VfsEntryType { | 22 | enum class VfsEntryType { |
| 24 | None, | 23 | None, |
| @@ -49,9 +48,9 @@ public: | |||
| 49 | virtual VfsEntryType GetEntryType(std::string_view path) const; | 48 | virtual VfsEntryType GetEntryType(std::string_view path) const; |
| 50 | 49 | ||
| 51 | // Opens the file with path relative to root. If it doesn't exist, returns nullptr. | 50 | // Opens the file with path relative to root. If it doesn't exist, returns nullptr. |
| 52 | virtual VirtualFile OpenFile(std::string_view path, Mode perms); | 51 | virtual VirtualFile OpenFile(std::string_view path, OpenMode perms); |
| 53 | // Creates a new, empty file at path | 52 | // Creates a new, empty file at path |
| 54 | virtual VirtualFile CreateFile(std::string_view path, Mode perms); | 53 | virtual VirtualFile CreateFile(std::string_view path, OpenMode perms); |
| 55 | // Copies the file from old_path to new_path, returning the new file on success and nullptr on | 54 | // Copies the file from old_path to new_path, returning the new file on success and nullptr on |
| 56 | // failure. | 55 | // failure. |
| 57 | virtual VirtualFile CopyFile(std::string_view old_path, std::string_view new_path); | 56 | virtual VirtualFile CopyFile(std::string_view old_path, std::string_view new_path); |
| @@ -62,9 +61,9 @@ public: | |||
| 62 | virtual bool DeleteFile(std::string_view path); | 61 | virtual bool DeleteFile(std::string_view path); |
| 63 | 62 | ||
| 64 | // Opens the directory with path relative to root. If it doesn't exist, returns nullptr. | 63 | // Opens the directory with path relative to root. If it doesn't exist, returns nullptr. |
| 65 | virtual VirtualDir OpenDirectory(std::string_view path, Mode perms); | 64 | virtual VirtualDir OpenDirectory(std::string_view path, OpenMode perms); |
| 66 | // Creates a new, empty directory at path | 65 | // Creates a new, empty directory at path |
| 67 | virtual VirtualDir CreateDirectory(std::string_view path, Mode perms); | 66 | virtual VirtualDir CreateDirectory(std::string_view path, OpenMode perms); |
| 68 | // Copies the directory from old_path to new_path, returning the new directory on success and | 67 | // Copies the directory from old_path to new_path, returning the new directory on success and |
| 69 | // nullptr on failure. | 68 | // nullptr on failure. |
| 70 | virtual VirtualDir CopyDirectory(std::string_view old_path, std::string_view new_path); | 69 | virtual VirtualDir CopyDirectory(std::string_view old_path, std::string_view new_path); |
diff --git a/src/core/file_sys/vfs/vfs_real.cpp b/src/core/file_sys/vfs/vfs_real.cpp index 1e6d8163b..627d5d251 100644 --- a/src/core/file_sys/vfs/vfs_real.cpp +++ b/src/core/file_sys/vfs/vfs_real.cpp | |||
| @@ -28,16 +28,14 @@ namespace { | |||
| 28 | 28 | ||
| 29 | constexpr size_t MaxOpenFiles = 512; | 29 | constexpr size_t MaxOpenFiles = 512; |
| 30 | 30 | ||
| 31 | constexpr FS::FileAccessMode ModeFlagsToFileAccessMode(Mode mode) { | 31 | constexpr FS::FileAccessMode ModeFlagsToFileAccessMode(OpenMode mode) { |
| 32 | switch (mode) { | 32 | switch (mode) { |
| 33 | case Mode::Read: | 33 | case OpenMode::Read: |
| 34 | return FS::FileAccessMode::Read; | 34 | return FS::FileAccessMode::Read; |
| 35 | case Mode::Write: | 35 | case OpenMode::Write: |
| 36 | case Mode::ReadWrite: | 36 | case OpenMode::ReadWrite: |
| 37 | case Mode::Append: | 37 | case OpenMode::AllowAppend: |
| 38 | case Mode::ReadAppend: | 38 | case OpenMode::All: |
| 39 | case Mode::WriteAppend: | ||
| 40 | case Mode::All: | ||
| 41 | return FS::FileAccessMode::ReadWrite; | 39 | return FS::FileAccessMode::ReadWrite; |
| 42 | default: | 40 | default: |
| 43 | return {}; | 41 | return {}; |
| @@ -74,7 +72,7 @@ VfsEntryType RealVfsFilesystem::GetEntryType(std::string_view path_) const { | |||
| 74 | } | 72 | } |
| 75 | 73 | ||
| 76 | VirtualFile RealVfsFilesystem::OpenFileFromEntry(std::string_view path_, std::optional<u64> size, | 74 | VirtualFile RealVfsFilesystem::OpenFileFromEntry(std::string_view path_, std::optional<u64> size, |
| 77 | Mode perms) { | 75 | OpenMode perms) { |
| 78 | const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault); | 76 | const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault); |
| 79 | std::scoped_lock lk{list_lock}; | 77 | std::scoped_lock lk{list_lock}; |
| 80 | 78 | ||
| @@ -98,11 +96,11 @@ VirtualFile RealVfsFilesystem::OpenFileFromEntry(std::string_view path_, std::op | |||
| 98 | return file; | 96 | return file; |
| 99 | } | 97 | } |
| 100 | 98 | ||
| 101 | VirtualFile RealVfsFilesystem::OpenFile(std::string_view path_, Mode perms) { | 99 | VirtualFile RealVfsFilesystem::OpenFile(std::string_view path_, OpenMode perms) { |
| 102 | return OpenFileFromEntry(path_, {}, perms); | 100 | return OpenFileFromEntry(path_, {}, perms); |
| 103 | } | 101 | } |
| 104 | 102 | ||
| 105 | VirtualFile RealVfsFilesystem::CreateFile(std::string_view path_, Mode perms) { | 103 | VirtualFile RealVfsFilesystem::CreateFile(std::string_view path_, OpenMode perms) { |
| 106 | const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault); | 104 | const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault); |
| 107 | { | 105 | { |
| 108 | std::scoped_lock lk{list_lock}; | 106 | std::scoped_lock lk{list_lock}; |
| @@ -145,7 +143,7 @@ VirtualFile RealVfsFilesystem::MoveFile(std::string_view old_path_, std::string_ | |||
| 145 | if (!FS::RenameFile(old_path, new_path)) { | 143 | if (!FS::RenameFile(old_path, new_path)) { |
| 146 | return nullptr; | 144 | return nullptr; |
| 147 | } | 145 | } |
| 148 | return OpenFile(new_path, Mode::ReadWrite); | 146 | return OpenFile(new_path, OpenMode::ReadWrite); |
| 149 | } | 147 | } |
| 150 | 148 | ||
| 151 | bool RealVfsFilesystem::DeleteFile(std::string_view path_) { | 149 | bool RealVfsFilesystem::DeleteFile(std::string_view path_) { |
| @@ -157,12 +155,12 @@ bool RealVfsFilesystem::DeleteFile(std::string_view path_) { | |||
| 157 | return FS::RemoveFile(path); | 155 | return FS::RemoveFile(path); |
| 158 | } | 156 | } |
| 159 | 157 | ||
| 160 | VirtualDir RealVfsFilesystem::OpenDirectory(std::string_view path_, Mode perms) { | 158 | VirtualDir RealVfsFilesystem::OpenDirectory(std::string_view path_, OpenMode perms) { |
| 161 | const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault); | 159 | const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault); |
| 162 | return std::shared_ptr<RealVfsDirectory>(new RealVfsDirectory(*this, path, perms)); | 160 | return std::shared_ptr<RealVfsDirectory>(new RealVfsDirectory(*this, path, perms)); |
| 163 | } | 161 | } |
| 164 | 162 | ||
| 165 | VirtualDir RealVfsFilesystem::CreateDirectory(std::string_view path_, Mode perms) { | 163 | VirtualDir RealVfsFilesystem::CreateDirectory(std::string_view path_, OpenMode perms) { |
| 166 | const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault); | 164 | const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault); |
| 167 | if (!FS::CreateDirs(path)) { | 165 | if (!FS::CreateDirs(path)) { |
| 168 | return nullptr; | 166 | return nullptr; |
| @@ -184,7 +182,7 @@ VirtualDir RealVfsFilesystem::MoveDirectory(std::string_view old_path_, | |||
| 184 | if (!FS::RenameDir(old_path, new_path)) { | 182 | if (!FS::RenameDir(old_path, new_path)) { |
| 185 | return nullptr; | 183 | return nullptr; |
| 186 | } | 184 | } |
| 187 | return OpenDirectory(new_path, Mode::ReadWrite); | 185 | return OpenDirectory(new_path, OpenMode::ReadWrite); |
| 188 | } | 186 | } |
| 189 | 187 | ||
| 190 | bool RealVfsFilesystem::DeleteDirectory(std::string_view path_) { | 188 | bool RealVfsFilesystem::DeleteDirectory(std::string_view path_) { |
| @@ -193,7 +191,7 @@ bool RealVfsFilesystem::DeleteDirectory(std::string_view path_) { | |||
| 193 | } | 191 | } |
| 194 | 192 | ||
| 195 | std::unique_lock<std::mutex> RealVfsFilesystem::RefreshReference(const std::string& path, | 193 | std::unique_lock<std::mutex> RealVfsFilesystem::RefreshReference(const std::string& path, |
| 196 | Mode perms, | 194 | OpenMode perms, |
| 197 | FileReference& reference) { | 195 | FileReference& reference) { |
| 198 | std::unique_lock lk{list_lock}; | 196 | std::unique_lock lk{list_lock}; |
| 199 | 197 | ||
| @@ -266,7 +264,7 @@ void RealVfsFilesystem::RemoveReferenceFromListLocked(FileReference& reference) | |||
| 266 | } | 264 | } |
| 267 | 265 | ||
| 268 | RealVfsFile::RealVfsFile(RealVfsFilesystem& base_, std::unique_ptr<FileReference> reference_, | 266 | RealVfsFile::RealVfsFile(RealVfsFilesystem& base_, std::unique_ptr<FileReference> reference_, |
| 269 | const std::string& path_, Mode perms_, std::optional<u64> size_) | 267 | const std::string& path_, OpenMode perms_, std::optional<u64> size_) |
| 270 | : base(base_), reference(std::move(reference_)), path(path_), | 268 | : base(base_), reference(std::move(reference_)), path(path_), |
| 271 | parent_path(FS::GetParentPath(path_)), path_components(FS::SplitPathComponentsCopy(path_)), | 269 | parent_path(FS::GetParentPath(path_)), path_components(FS::SplitPathComponentsCopy(path_)), |
| 272 | size(size_), perms(perms_) {} | 270 | size(size_), perms(perms_) {} |
| @@ -298,11 +296,11 @@ VirtualDir RealVfsFile::GetContainingDirectory() const { | |||
| 298 | } | 296 | } |
| 299 | 297 | ||
| 300 | bool RealVfsFile::IsWritable() const { | 298 | bool RealVfsFile::IsWritable() const { |
| 301 | return True(perms & Mode::Write); | 299 | return True(perms & OpenMode::Write); |
| 302 | } | 300 | } |
| 303 | 301 | ||
| 304 | bool RealVfsFile::IsReadable() const { | 302 | bool RealVfsFile::IsReadable() const { |
| 305 | return True(perms & Mode::Read); | 303 | return True(perms & OpenMode::Read); |
| 306 | } | 304 | } |
| 307 | 305 | ||
| 308 | std::size_t RealVfsFile::Read(u8* data, std::size_t length, std::size_t offset) const { | 306 | std::size_t RealVfsFile::Read(u8* data, std::size_t length, std::size_t offset) const { |
| @@ -331,7 +329,7 @@ bool RealVfsFile::Rename(std::string_view name) { | |||
| 331 | 329 | ||
| 332 | template <> | 330 | template <> |
| 333 | std::vector<VirtualFile> RealVfsDirectory::IterateEntries<RealVfsFile, VfsFile>() const { | 331 | std::vector<VirtualFile> RealVfsDirectory::IterateEntries<RealVfsFile, VfsFile>() const { |
| 334 | if (perms == Mode::Append) { | 332 | if (perms == OpenMode::AllowAppend) { |
| 335 | return {}; | 333 | return {}; |
| 336 | } | 334 | } |
| 337 | 335 | ||
| @@ -353,7 +351,7 @@ std::vector<VirtualFile> RealVfsDirectory::IterateEntries<RealVfsFile, VfsFile>( | |||
| 353 | 351 | ||
| 354 | template <> | 352 | template <> |
| 355 | std::vector<VirtualDir> RealVfsDirectory::IterateEntries<RealVfsDirectory, VfsDirectory>() const { | 353 | std::vector<VirtualDir> RealVfsDirectory::IterateEntries<RealVfsDirectory, VfsDirectory>() const { |
| 356 | if (perms == Mode::Append) { | 354 | if (perms == OpenMode::AllowAppend) { |
| 357 | return {}; | 355 | return {}; |
| 358 | } | 356 | } |
| 359 | 357 | ||
| @@ -373,10 +371,11 @@ std::vector<VirtualDir> RealVfsDirectory::IterateEntries<RealVfsDirectory, VfsDi | |||
| 373 | return out; | 371 | return out; |
| 374 | } | 372 | } |
| 375 | 373 | ||
| 376 | RealVfsDirectory::RealVfsDirectory(RealVfsFilesystem& base_, const std::string& path_, Mode perms_) | 374 | RealVfsDirectory::RealVfsDirectory(RealVfsFilesystem& base_, const std::string& path_, |
| 375 | OpenMode perms_) | ||
| 377 | : base(base_), path(FS::RemoveTrailingSlash(path_)), parent_path(FS::GetParentPath(path)), | 376 | : base(base_), path(FS::RemoveTrailingSlash(path_)), parent_path(FS::GetParentPath(path)), |
| 378 | path_components(FS::SplitPathComponentsCopy(path)), perms(perms_) { | 377 | path_components(FS::SplitPathComponentsCopy(path)), perms(perms_) { |
| 379 | if (!FS::Exists(path) && True(perms & Mode::Write)) { | 378 | if (!FS::Exists(path) && True(perms & OpenMode::Write)) { |
| 380 | void(FS::CreateDirs(path)); | 379 | void(FS::CreateDirs(path)); |
| 381 | } | 380 | } |
| 382 | } | 381 | } |
| @@ -456,11 +455,11 @@ std::vector<VirtualDir> RealVfsDirectory::GetSubdirectories() const { | |||
| 456 | } | 455 | } |
| 457 | 456 | ||
| 458 | bool RealVfsDirectory::IsWritable() const { | 457 | bool RealVfsDirectory::IsWritable() const { |
| 459 | return True(perms & Mode::Write); | 458 | return True(perms & OpenMode::Write); |
| 460 | } | 459 | } |
| 461 | 460 | ||
| 462 | bool RealVfsDirectory::IsReadable() const { | 461 | bool RealVfsDirectory::IsReadable() const { |
| 463 | return True(perms & Mode::Read); | 462 | return True(perms & OpenMode::Read); |
| 464 | } | 463 | } |
| 465 | 464 | ||
| 466 | std::string RealVfsDirectory::GetName() const { | 465 | std::string RealVfsDirectory::GetName() const { |
| @@ -507,7 +506,7 @@ std::string RealVfsDirectory::GetFullPath() const { | |||
| 507 | } | 506 | } |
| 508 | 507 | ||
| 509 | std::map<std::string, VfsEntryType, std::less<>> RealVfsDirectory::GetEntries() const { | 508 | std::map<std::string, VfsEntryType, std::less<>> RealVfsDirectory::GetEntries() const { |
| 510 | if (perms == Mode::Append) { | 509 | if (perms == OpenMode::AllowAppend) { |
| 511 | return {}; | 510 | return {}; |
| 512 | } | 511 | } |
| 513 | 512 | ||
diff --git a/src/core/file_sys/vfs/vfs_real.h b/src/core/file_sys/vfs/vfs_real.h index 1560bc1f9..5c2172cce 100644 --- a/src/core/file_sys/vfs/vfs_real.h +++ b/src/core/file_sys/vfs/vfs_real.h | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | #include <optional> | 8 | #include <optional> |
| 9 | #include <string_view> | 9 | #include <string_view> |
| 10 | #include "common/intrusive_list.h" | 10 | #include "common/intrusive_list.h" |
| 11 | #include "core/file_sys/mode.h" | 11 | #include "core/file_sys/fs_filesystem.h" |
| 12 | #include "core/file_sys/vfs/vfs.h" | 12 | #include "core/file_sys/vfs/vfs.h" |
| 13 | 13 | ||
| 14 | namespace Common::FS { | 14 | namespace Common::FS { |
| @@ -33,13 +33,14 @@ public: | |||
| 33 | bool IsReadable() const override; | 33 | bool IsReadable() const override; |
| 34 | bool IsWritable() const override; | 34 | bool IsWritable() const override; |
| 35 | VfsEntryType GetEntryType(std::string_view path) const override; | 35 | VfsEntryType GetEntryType(std::string_view path) const override; |
| 36 | VirtualFile OpenFile(std::string_view path, Mode perms = Mode::Read) override; | 36 | VirtualFile OpenFile(std::string_view path, OpenMode perms = OpenMode::Read) override; |
| 37 | VirtualFile CreateFile(std::string_view path, Mode perms = Mode::ReadWrite) override; | 37 | VirtualFile CreateFile(std::string_view path, OpenMode perms = OpenMode::ReadWrite) override; |
| 38 | VirtualFile CopyFile(std::string_view old_path, std::string_view new_path) override; | 38 | VirtualFile CopyFile(std::string_view old_path, std::string_view new_path) override; |
| 39 | VirtualFile MoveFile(std::string_view old_path, std::string_view new_path) override; | 39 | VirtualFile MoveFile(std::string_view old_path, std::string_view new_path) override; |
| 40 | bool DeleteFile(std::string_view path) override; | 40 | bool DeleteFile(std::string_view path) override; |
| 41 | VirtualDir OpenDirectory(std::string_view path, Mode perms = Mode::Read) override; | 41 | VirtualDir OpenDirectory(std::string_view path, OpenMode perms = OpenMode::Read) override; |
| 42 | VirtualDir CreateDirectory(std::string_view path, Mode perms = Mode::ReadWrite) override; | 42 | VirtualDir CreateDirectory(std::string_view path, |
| 43 | OpenMode perms = OpenMode::ReadWrite) override; | ||
| 43 | VirtualDir CopyDirectory(std::string_view old_path, std::string_view new_path) override; | 44 | VirtualDir CopyDirectory(std::string_view old_path, std::string_view new_path) override; |
| 44 | VirtualDir MoveDirectory(std::string_view old_path, std::string_view new_path) override; | 45 | VirtualDir MoveDirectory(std::string_view old_path, std::string_view new_path) override; |
| 45 | bool DeleteDirectory(std::string_view path) override; | 46 | bool DeleteDirectory(std::string_view path) override; |
| @@ -54,14 +55,14 @@ private: | |||
| 54 | 55 | ||
| 55 | private: | 56 | private: |
| 56 | friend class RealVfsFile; | 57 | friend class RealVfsFile; |
| 57 | std::unique_lock<std::mutex> RefreshReference(const std::string& path, Mode perms, | 58 | std::unique_lock<std::mutex> RefreshReference(const std::string& path, OpenMode perms, |
| 58 | FileReference& reference); | 59 | FileReference& reference); |
| 59 | void DropReference(std::unique_ptr<FileReference>&& reference); | 60 | void DropReference(std::unique_ptr<FileReference>&& reference); |
| 60 | 61 | ||
| 61 | private: | 62 | private: |
| 62 | friend class RealVfsDirectory; | 63 | friend class RealVfsDirectory; |
| 63 | VirtualFile OpenFileFromEntry(std::string_view path, std::optional<u64> size, | 64 | VirtualFile OpenFileFromEntry(std::string_view path, std::optional<u64> size, |
| 64 | Mode perms = Mode::Read); | 65 | OpenMode perms = OpenMode::Read); |
| 65 | 66 | ||
| 66 | private: | 67 | private: |
| 67 | void EvictSingleReferenceLocked(); | 68 | void EvictSingleReferenceLocked(); |
| @@ -89,7 +90,8 @@ public: | |||
| 89 | 90 | ||
| 90 | private: | 91 | private: |
| 91 | RealVfsFile(RealVfsFilesystem& base, std::unique_ptr<FileReference> reference, | 92 | RealVfsFile(RealVfsFilesystem& base, std::unique_ptr<FileReference> reference, |
| 92 | const std::string& path, Mode perms = Mode::Read, std::optional<u64> size = {}); | 93 | const std::string& path, OpenMode perms = OpenMode::Read, |
| 94 | std::optional<u64> size = {}); | ||
| 93 | 95 | ||
| 94 | RealVfsFilesystem& base; | 96 | RealVfsFilesystem& base; |
| 95 | std::unique_ptr<FileReference> reference; | 97 | std::unique_ptr<FileReference> reference; |
| @@ -97,7 +99,7 @@ private: | |||
| 97 | std::string parent_path; | 99 | std::string parent_path; |
| 98 | std::vector<std::string> path_components; | 100 | std::vector<std::string> path_components; |
| 99 | std::optional<u64> size; | 101 | std::optional<u64> size; |
| 100 | Mode perms; | 102 | OpenMode perms; |
| 101 | }; | 103 | }; |
| 102 | 104 | ||
| 103 | // An implementation of VfsDirectory that represents a directory on the user's computer. | 105 | // An implementation of VfsDirectory that represents a directory on the user's computer. |
| @@ -130,7 +132,8 @@ public: | |||
| 130 | std::map<std::string, VfsEntryType, std::less<>> GetEntries() const override; | 132 | std::map<std::string, VfsEntryType, std::less<>> GetEntries() const override; |
| 131 | 133 | ||
| 132 | private: | 134 | private: |
| 133 | RealVfsDirectory(RealVfsFilesystem& base, const std::string& path, Mode perms = Mode::Read); | 135 | RealVfsDirectory(RealVfsFilesystem& base, const std::string& path, |
| 136 | OpenMode perms = OpenMode::Read); | ||
| 134 | 137 | ||
| 135 | template <typename T, typename R> | 138 | template <typename T, typename R> |
| 136 | std::vector<std::shared_ptr<R>> IterateEntries() const; | 139 | std::vector<std::shared_ptr<R>> IterateEntries() const; |
| @@ -139,7 +142,7 @@ private: | |||
| 139 | std::string path; | 142 | std::string path; |
| 140 | std::string parent_path; | 143 | std::string parent_path; |
| 141 | std::vector<std::string> path_components; | 144 | std::vector<std::string> path_components; |
| 142 | Mode perms; | 145 | OpenMode perms; |
| 143 | }; | 146 | }; |
| 144 | 147 | ||
| 145 | } // namespace FileSys | 148 | } // namespace FileSys |
diff --git a/src/core/hle/service/am/applets/applet_web_browser.cpp b/src/core/hle/service/am/applets/applet_web_browser.cpp index 0c826ded7..19057ad7b 100644 --- a/src/core/hle/service/am/applets/applet_web_browser.cpp +++ b/src/core/hle/service/am/applets/applet_web_browser.cpp | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include "common/string_util.h" | 9 | #include "common/string_util.h" |
| 10 | #include "core/core.h" | 10 | #include "core/core.h" |
| 11 | #include "core/file_sys/content_archive.h" | 11 | #include "core/file_sys/content_archive.h" |
| 12 | #include "core/file_sys/mode.h" | 12 | #include "core/file_sys/fs_filesystem.h" |
| 13 | #include "core/file_sys/nca_metadata.h" | 13 | #include "core/file_sys/nca_metadata.h" |
| 14 | #include "core/file_sys/patch_manager.h" | 14 | #include "core/file_sys/patch_manager.h" |
| 15 | #include "core/file_sys/registered_cache.h" | 15 | #include "core/file_sys/registered_cache.h" |
| @@ -213,7 +213,7 @@ void ExtractSharedFonts(Core::System& system) { | |||
| 213 | std::move(decrypted_data), DECRYPTED_SHARED_FONTS[i]); | 213 | std::move(decrypted_data), DECRYPTED_SHARED_FONTS[i]); |
| 214 | 214 | ||
| 215 | const auto temp_dir = system.GetFilesystem()->CreateDirectory( | 215 | const auto temp_dir = system.GetFilesystem()->CreateDirectory( |
| 216 | Common::FS::PathToUTF8String(fonts_dir), FileSys::Mode::ReadWrite); | 216 | Common::FS::PathToUTF8String(fonts_dir), FileSys::OpenMode::ReadWrite); |
| 217 | 217 | ||
| 218 | const auto out_file = temp_dir->CreateFile(DECRYPTED_SHARED_FONTS[i]); | 218 | const auto out_file = temp_dir->CreateFile(DECRYPTED_SHARED_FONTS[i]); |
| 219 | 219 | ||
| @@ -333,7 +333,7 @@ void WebBrowser::ExtractOfflineRomFS() { | |||
| 333 | const auto extracted_romfs_dir = FileSys::ExtractRomFS(offline_romfs); | 333 | const auto extracted_romfs_dir = FileSys::ExtractRomFS(offline_romfs); |
| 334 | 334 | ||
| 335 | const auto temp_dir = system.GetFilesystem()->CreateDirectory( | 335 | const auto temp_dir = system.GetFilesystem()->CreateDirectory( |
| 336 | Common::FS::PathToUTF8String(offline_cache_dir), FileSys::Mode::ReadWrite); | 336 | Common::FS::PathToUTF8String(offline_cache_dir), FileSys::OpenMode::ReadWrite); |
| 337 | 337 | ||
| 338 | FileSys::VfsRawCopyD(extracted_romfs_dir, temp_dir); | 338 | FileSys::VfsRawCopyD(extracted_romfs_dir, temp_dir); |
| 339 | } | 339 | } |
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index 4ae6ef0bd..eb8c3c23e 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | #include "core/file_sys/card_image.h" | 12 | #include "core/file_sys/card_image.h" |
| 13 | #include "core/file_sys/control_metadata.h" | 13 | #include "core/file_sys/control_metadata.h" |
| 14 | #include "core/file_sys/errors.h" | 14 | #include "core/file_sys/errors.h" |
| 15 | #include "core/file_sys/mode.h" | ||
| 16 | #include "core/file_sys/patch_manager.h" | 15 | #include "core/file_sys/patch_manager.h" |
| 17 | #include "core/file_sys/registered_cache.h" | 16 | #include "core/file_sys/registered_cache.h" |
| 18 | #include "core/file_sys/romfs_factory.h" | 17 | #include "core/file_sys/romfs_factory.h" |
| @@ -56,7 +55,7 @@ Result VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 size | |||
| 56 | return FileSys::ERROR_PATH_NOT_FOUND; | 55 | return FileSys::ERROR_PATH_NOT_FOUND; |
| 57 | } | 56 | } |
| 58 | 57 | ||
| 59 | FileSys::EntryType entry_type{}; | 58 | FileSys::DirectoryEntryType entry_type{}; |
| 60 | if (GetEntryType(&entry_type, path) == ResultSuccess) { | 59 | if (GetEntryType(&entry_type, path) == ResultSuccess) { |
| 61 | return FileSys::ERROR_PATH_ALREADY_EXISTS; | 60 | return FileSys::ERROR_PATH_ALREADY_EXISTS; |
| 62 | } | 61 | } |
| @@ -214,7 +213,8 @@ Result VfsDirectoryServiceWrapper::RenameDirectory(const std::string& src_path_, | |||
| 214 | } | 213 | } |
| 215 | 214 | ||
| 216 | Result VfsDirectoryServiceWrapper::OpenFile(FileSys::VirtualFile* out_file, | 215 | Result VfsDirectoryServiceWrapper::OpenFile(FileSys::VirtualFile* out_file, |
| 217 | const std::string& path_, FileSys::Mode mode) const { | 216 | const std::string& path_, |
| 217 | FileSys::OpenMode mode) const { | ||
| 218 | const std::string path(Common::FS::SanitizePath(path_)); | 218 | const std::string path(Common::FS::SanitizePath(path_)); |
| 219 | std::string_view npath = path; | 219 | std::string_view npath = path; |
| 220 | while (!npath.empty() && (npath[0] == '/' || npath[0] == '\\')) { | 220 | while (!npath.empty() && (npath[0] == '/' || npath[0] == '\\')) { |
| @@ -226,7 +226,7 @@ Result VfsDirectoryServiceWrapper::OpenFile(FileSys::VirtualFile* out_file, | |||
| 226 | return FileSys::ERROR_PATH_NOT_FOUND; | 226 | return FileSys::ERROR_PATH_NOT_FOUND; |
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | if (mode == FileSys::Mode::Append) { | 229 | if (mode == FileSys::OpenMode::AllowAppend) { |
| 230 | *out_file = std::make_shared<FileSys::OffsetVfsFile>(file, 0, file->GetSize()); | 230 | *out_file = std::make_shared<FileSys::OffsetVfsFile>(file, 0, file->GetSize()); |
| 231 | } else { | 231 | } else { |
| 232 | *out_file = file; | 232 | *out_file = file; |
| @@ -247,7 +247,7 @@ Result VfsDirectoryServiceWrapper::OpenDirectory(FileSys::VirtualDir* out_direct | |||
| 247 | return ResultSuccess; | 247 | return ResultSuccess; |
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | Result VfsDirectoryServiceWrapper::GetEntryType(FileSys::EntryType* out_entry_type, | 250 | Result VfsDirectoryServiceWrapper::GetEntryType(FileSys::DirectoryEntryType* out_entry_type, |
| 251 | const std::string& path_) const { | 251 | const std::string& path_) const { |
| 252 | std::string path(Common::FS::SanitizePath(path_)); | 252 | std::string path(Common::FS::SanitizePath(path_)); |
| 253 | auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path)); | 253 | auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path)); |
| @@ -258,17 +258,17 @@ Result VfsDirectoryServiceWrapper::GetEntryType(FileSys::EntryType* out_entry_ty | |||
| 258 | auto filename = Common::FS::GetFilename(path); | 258 | auto filename = Common::FS::GetFilename(path); |
| 259 | // TODO(Subv): Some games use the '/' path, find out what this means. | 259 | // TODO(Subv): Some games use the '/' path, find out what this means. |
| 260 | if (filename.empty()) { | 260 | if (filename.empty()) { |
| 261 | *out_entry_type = FileSys::EntryType::Directory; | 261 | *out_entry_type = FileSys::DirectoryEntryType::Directory; |
| 262 | return ResultSuccess; | 262 | return ResultSuccess; |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | if (dir->GetFile(filename) != nullptr) { | 265 | if (dir->GetFile(filename) != nullptr) { |
| 266 | *out_entry_type = FileSys::EntryType::File; | 266 | *out_entry_type = FileSys::DirectoryEntryType::File; |
| 267 | return ResultSuccess; | 267 | return ResultSuccess; |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | if (dir->GetSubdirectory(filename) != nullptr) { | 270 | if (dir->GetSubdirectory(filename) != nullptr) { |
| 271 | *out_entry_type = FileSys::EntryType::Directory; | 271 | *out_entry_type = FileSys::DirectoryEntryType::Directory; |
| 272 | return ResultSuccess; | 272 | return ResultSuccess; |
| 273 | } | 273 | } |
| 274 | 274 | ||
| @@ -282,7 +282,7 @@ Result VfsDirectoryServiceWrapper::GetFileTimeStampRaw( | |||
| 282 | return FileSys::ERROR_PATH_NOT_FOUND; | 282 | return FileSys::ERROR_PATH_NOT_FOUND; |
| 283 | } | 283 | } |
| 284 | 284 | ||
| 285 | FileSys::EntryType entry_type; | 285 | FileSys::DirectoryEntryType entry_type; |
| 286 | if (GetEntryType(&entry_type, path) != ResultSuccess) { | 286 | if (GetEntryType(&entry_type, path) != ResultSuccess) { |
| 287 | return FileSys::ERROR_PATH_NOT_FOUND; | 287 | return FileSys::ERROR_PATH_NOT_FOUND; |
| 288 | } | 288 | } |
| @@ -347,7 +347,7 @@ std::shared_ptr<SaveDataController> FileSystemController::OpenSaveDataController | |||
| 347 | std::shared_ptr<FileSys::SaveDataFactory> FileSystemController::CreateSaveDataFactory( | 347 | std::shared_ptr<FileSys::SaveDataFactory> FileSystemController::CreateSaveDataFactory( |
| 348 | ProgramId program_id) { | 348 | ProgramId program_id) { |
| 349 | using YuzuPath = Common::FS::YuzuPath; | 349 | using YuzuPath = Common::FS::YuzuPath; |
| 350 | const auto rw_mode = FileSys::Mode::ReadWrite; | 350 | const auto rw_mode = FileSys::OpenMode::ReadWrite; |
| 351 | 351 | ||
| 352 | auto vfs = system.GetFilesystem(); | 352 | auto vfs = system.GetFilesystem(); |
| 353 | const auto nand_directory = | 353 | const auto nand_directory = |
| @@ -686,15 +686,15 @@ void FileSystemController::CreateFactories(FileSys::VfsFilesystem& vfs, bool ove | |||
| 686 | using YuzuPath = Common::FS::YuzuPath; | 686 | using YuzuPath = Common::FS::YuzuPath; |
| 687 | const auto sdmc_dir_path = Common::FS::GetYuzuPath(YuzuPath::SDMCDir); | 687 | const auto sdmc_dir_path = Common::FS::GetYuzuPath(YuzuPath::SDMCDir); |
| 688 | const auto sdmc_load_dir_path = sdmc_dir_path / "atmosphere/contents"; | 688 | const auto sdmc_load_dir_path = sdmc_dir_path / "atmosphere/contents"; |
| 689 | const auto rw_mode = FileSys::Mode::ReadWrite; | 689 | const auto rw_mode = FileSys::OpenMode::ReadWrite; |
| 690 | 690 | ||
| 691 | auto nand_directory = | 691 | auto nand_directory = |
| 692 | vfs.OpenDirectory(Common::FS::GetYuzuPathString(YuzuPath::NANDDir), rw_mode); | 692 | vfs.OpenDirectory(Common::FS::GetYuzuPathString(YuzuPath::NANDDir), rw_mode); |
| 693 | auto sd_directory = vfs.OpenDirectory(Common::FS::PathToUTF8String(sdmc_dir_path), rw_mode); | 693 | auto sd_directory = vfs.OpenDirectory(Common::FS::PathToUTF8String(sdmc_dir_path), rw_mode); |
| 694 | auto load_directory = | 694 | auto load_directory = vfs.OpenDirectory(Common::FS::GetYuzuPathString(YuzuPath::LoadDir), |
| 695 | vfs.OpenDirectory(Common::FS::GetYuzuPathString(YuzuPath::LoadDir), FileSys::Mode::Read); | 695 | FileSys::OpenMode::Read); |
| 696 | auto sd_load_directory = | 696 | auto sd_load_directory = vfs.OpenDirectory(Common::FS::PathToUTF8String(sdmc_load_dir_path), |
| 697 | vfs.OpenDirectory(Common::FS::PathToUTF8String(sdmc_load_dir_path), FileSys::Mode::Read); | 697 | FileSys::OpenMode::Read); |
| 698 | auto dump_directory = | 698 | auto dump_directory = |
| 699 | vfs.OpenDirectory(Common::FS::GetYuzuPathString(YuzuPath::DumpDir), rw_mode); | 699 | vfs.OpenDirectory(Common::FS::GetYuzuPathString(YuzuPath::DumpDir), rw_mode); |
| 700 | 700 | ||
diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h index 65dcdb514..2413cdb5c 100644 --- a/src/core/hle/service/filesystem/filesystem.h +++ b/src/core/hle/service/filesystem/filesystem.h | |||
| @@ -5,7 +5,8 @@ | |||
| 5 | 5 | ||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | #include "core/file_sys/directory.h" | 8 | #include "core/file_sys/fs_directory.h" |
| 9 | #include "core/file_sys/fs_filesystem.h" | ||
| 9 | #include "core/file_sys/vfs/vfs.h" | 10 | #include "core/file_sys/vfs/vfs.h" |
| 10 | #include "core/hle/result.h" | 11 | #include "core/hle/result.h" |
| 11 | 12 | ||
| @@ -26,7 +27,6 @@ class XCI; | |||
| 26 | 27 | ||
| 27 | enum class BisPartitionId : u32; | 28 | enum class BisPartitionId : u32; |
| 28 | enum class ContentRecordType : u8; | 29 | enum class ContentRecordType : u8; |
| 29 | enum class Mode : u32; | ||
| 30 | enum class SaveDataSpaceId : u8; | 30 | enum class SaveDataSpaceId : u8; |
| 31 | enum class SaveDataType : u8; | 31 | enum class SaveDataType : u8; |
| 32 | enum class StorageId : u8; | 32 | enum class StorageId : u8; |
| @@ -57,13 +57,6 @@ enum class ImageDirectoryId : u32 { | |||
| 57 | SdCard, | 57 | SdCard, |
| 58 | }; | 58 | }; |
| 59 | 59 | ||
| 60 | enum class OpenDirectoryMode : u64 { | ||
| 61 | Directory = (1 << 0), | ||
| 62 | File = (1 << 1), | ||
| 63 | All = Directory | File | ||
| 64 | }; | ||
| 65 | DECLARE_ENUM_FLAG_OPERATORS(OpenDirectoryMode); | ||
| 66 | |||
| 67 | using ProcessId = u64; | 60 | using ProcessId = u64; |
| 68 | using ProgramId = u64; | 61 | using ProgramId = u64; |
| 69 | 62 | ||
| @@ -237,7 +230,7 @@ public: | |||
| 237 | * @return Opened file, or error code | 230 | * @return Opened file, or error code |
| 238 | */ | 231 | */ |
| 239 | Result OpenFile(FileSys::VirtualFile* out_file, const std::string& path, | 232 | Result OpenFile(FileSys::VirtualFile* out_file, const std::string& path, |
| 240 | FileSys::Mode mode) const; | 233 | FileSys::OpenMode mode) const; |
| 241 | 234 | ||
| 242 | /** | 235 | /** |
| 243 | * Open a directory specified by its path | 236 | * Open a directory specified by its path |
| @@ -250,7 +243,7 @@ public: | |||
| 250 | * Get the type of the specified path | 243 | * Get the type of the specified path |
| 251 | * @return The type of the specified path or error code | 244 | * @return The type of the specified path or error code |
| 252 | */ | 245 | */ |
| 253 | Result GetEntryType(FileSys::EntryType* out_entry_type, const std::string& path) const; | 246 | Result GetEntryType(FileSys::DirectoryEntryType* out_entry_type, const std::string& path) const; |
| 254 | 247 | ||
| 255 | /** | 248 | /** |
| 256 | * Get the timestamp of the specified path | 249 | * Get the timestamp of the specified path |
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_directory.cpp b/src/core/hle/service/filesystem/fsp/fs_i_directory.cpp index 62512ad0f..1e8ef366e 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_directory.cpp +++ b/src/core/hle/service/filesystem/fsp/fs_i_directory.cpp | |||
| @@ -8,23 +8,26 @@ | |||
| 8 | namespace Service::FileSystem { | 8 | namespace Service::FileSystem { |
| 9 | 9 | ||
| 10 | template <typename T> | 10 | template <typename T> |
| 11 | static void BuildEntryIndex(std::vector<FileSys::Entry>& entries, const std::vector<T>& new_data, | 11 | static void BuildEntryIndex(std::vector<FileSys::DirectoryEntry>& entries, |
| 12 | FileSys::EntryType type) { | 12 | const std::vector<T>& new_data, FileSys::DirectoryEntryType type) { |
| 13 | entries.reserve(entries.size() + new_data.size()); | 13 | entries.reserve(entries.size() + new_data.size()); |
| 14 | 14 | ||
| 15 | for (const auto& new_entry : new_data) { | 15 | for (const auto& new_entry : new_data) { |
| 16 | auto name = new_entry->GetName(); | 16 | auto name = new_entry->GetName(); |
| 17 | 17 | ||
| 18 | if (type == FileSys::EntryType::File && name == FileSys::GetSaveDataSizeFileName()) { | 18 | if (type == FileSys::DirectoryEntryType::File && |
| 19 | name == FileSys::GetSaveDataSizeFileName()) { | ||
| 19 | continue; | 20 | continue; |
| 20 | } | 21 | } |
| 21 | 22 | ||
| 22 | entries.emplace_back(name, type, | 23 | entries.emplace_back(name, static_cast<s8>(type), |
| 23 | type == FileSys::EntryType::Directory ? 0 : new_entry->GetSize()); | 24 | type == FileSys::DirectoryEntryType::Directory ? 0 |
| 25 | : new_entry->GetSize()); | ||
| 24 | } | 26 | } |
| 25 | } | 27 | } |
| 26 | 28 | ||
| 27 | IDirectory::IDirectory(Core::System& system_, FileSys::VirtualDir backend_, OpenDirectoryMode mode) | 29 | IDirectory::IDirectory(Core::System& system_, FileSys::VirtualDir backend_, |
| 30 | FileSys::OpenDirectoryMode mode) | ||
| 28 | : ServiceFramework{system_, "IDirectory"}, backend(std::move(backend_)) { | 31 | : ServiceFramework{system_, "IDirectory"}, backend(std::move(backend_)) { |
| 29 | static const FunctionInfo functions[] = { | 32 | static const FunctionInfo functions[] = { |
| 30 | {0, &IDirectory::Read, "Read"}, | 33 | {0, &IDirectory::Read, "Read"}, |
| @@ -34,11 +37,12 @@ IDirectory::IDirectory(Core::System& system_, FileSys::VirtualDir backend_, Open | |||
| 34 | 37 | ||
| 35 | // TODO(DarkLordZach): Verify that this is the correct behavior. | 38 | // TODO(DarkLordZach): Verify that this is the correct behavior. |
| 36 | // Build entry index now to save time later. | 39 | // Build entry index now to save time later. |
| 37 | if (True(mode & OpenDirectoryMode::Directory)) { | 40 | if (True(mode & FileSys::OpenDirectoryMode::Directory)) { |
| 38 | BuildEntryIndex(entries, backend->GetSubdirectories(), FileSys::EntryType::Directory); | 41 | BuildEntryIndex(entries, backend->GetSubdirectories(), |
| 42 | FileSys::DirectoryEntryType::Directory); | ||
| 39 | } | 43 | } |
| 40 | if (True(mode & OpenDirectoryMode::File)) { | 44 | if (True(mode & FileSys::OpenDirectoryMode::File)) { |
| 41 | BuildEntryIndex(entries, backend->GetFiles(), FileSys::EntryType::File); | 45 | BuildEntryIndex(entries, backend->GetFiles(), FileSys::DirectoryEntryType::File); |
| 42 | } | 46 | } |
| 43 | } | 47 | } |
| 44 | 48 | ||
| @@ -46,7 +50,7 @@ void IDirectory::Read(HLERequestContext& ctx) { | |||
| 46 | LOG_DEBUG(Service_FS, "called."); | 50 | LOG_DEBUG(Service_FS, "called."); |
| 47 | 51 | ||
| 48 | // Calculate how many entries we can fit in the output buffer | 52 | // Calculate how many entries we can fit in the output buffer |
| 49 | const u64 count_entries = ctx.GetWriteBufferNumElements<FileSys::Entry>(); | 53 | const u64 count_entries = ctx.GetWriteBufferNumElements<FileSys::DirectoryEntry>(); |
| 50 | 54 | ||
| 51 | // Cap at total number of entries. | 55 | // Cap at total number of entries. |
| 52 | const u64 actual_entries = std::min(count_entries, entries.size() - next_entry_index); | 56 | const u64 actual_entries = std::min(count_entries, entries.size() - next_entry_index); |
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_directory.h b/src/core/hle/service/filesystem/fsp/fs_i_directory.h index ecc4ecada..9f5d7c054 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_directory.h +++ b/src/core/hle/service/filesystem/fsp/fs_i_directory.h | |||
| @@ -3,9 +3,10 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "core/file_sys/fs_filesystem.h" | ||
| 6 | #include "core/file_sys/vfs/vfs.h" | 7 | #include "core/file_sys/vfs/vfs.h" |
| 7 | #include "core/hle/service/filesystem/filesystem.h" | 8 | #include "core/hle/service/filesystem/filesystem.h" |
| 8 | #include "core/hle/service/filesystem/fsp_util.h" | 9 | #include "core/hle/service/filesystem/fsp/fsp_util.h" |
| 9 | #include "core/hle/service/service.h" | 10 | #include "core/hle/service/service.h" |
| 10 | 11 | ||
| 11 | namespace Service::FileSystem { | 12 | namespace Service::FileSystem { |
| @@ -13,11 +14,11 @@ namespace Service::FileSystem { | |||
| 13 | class IDirectory final : public ServiceFramework<IDirectory> { | 14 | class IDirectory final : public ServiceFramework<IDirectory> { |
| 14 | public: | 15 | public: |
| 15 | explicit IDirectory(Core::System& system_, FileSys::VirtualDir backend_, | 16 | explicit IDirectory(Core::System& system_, FileSys::VirtualDir backend_, |
| 16 | OpenDirectoryMode mode); | 17 | FileSys::OpenDirectoryMode mode); |
| 17 | 18 | ||
| 18 | private: | 19 | private: |
| 19 | FileSys::VirtualDir backend; | 20 | FileSys::VirtualDir backend; |
| 20 | std::vector<FileSys::Entry> entries; | 21 | std::vector<FileSys::DirectoryEntry> entries; |
| 21 | u64 next_entry_index = 0; | 22 | u64 next_entry_index = 0; |
| 22 | 23 | ||
| 23 | void Read(HLERequestContext& ctx); | 24 | void Read(HLERequestContext& ctx); |
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_file.h b/src/core/hle/service/filesystem/fsp/fs_i_file.h index a7eb1a1e9..5e5430c67 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_file.h +++ b/src/core/hle/service/filesystem/fsp/fs_i_file.h | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "core/file_sys/vfs.h" | ||
| 7 | #include "core/hle/service/filesystem/filesystem.h" | 6 | #include "core/hle/service/filesystem/filesystem.h" |
| 8 | #include "core/hle/service/service.h" | 7 | #include "core/hle/service/service.h" |
| 9 | 8 | ||
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 3e72101a4..efa394dd1 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp +++ b/src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp | |||
| @@ -10,8 +10,8 @@ | |||
| 10 | namespace Service::FileSystem { | 10 | namespace Service::FileSystem { |
| 11 | 11 | ||
| 12 | IFileSystem::IFileSystem(Core::System& system_, FileSys::VirtualDir backend_, SizeGetter size_) | 12 | IFileSystem::IFileSystem(Core::System& system_, FileSys::VirtualDir backend_, SizeGetter size_) |
| 13 | : ServiceFramework{system_, "IFileSystem"}, backend{std::move(backend_)}, | 13 | : ServiceFramework{system_, "IFileSystem"}, backend{std::move(backend_)}, size{std::move( |
| 14 | size{std::move(size_)} { | 14 | size_)} { |
| 15 | static const FunctionInfo functions[] = { | 15 | static const FunctionInfo functions[] = { |
| 16 | {0, &IFileSystem::CreateFile, "CreateFile"}, | 16 | {0, &IFileSystem::CreateFile, "CreateFile"}, |
| 17 | {1, &IFileSystem::DeleteFile, "DeleteFile"}, | 17 | {1, &IFileSystem::DeleteFile, "DeleteFile"}, |
| @@ -116,7 +116,7 @@ void IFileSystem::OpenFile(HLERequestContext& ctx) { | |||
| 116 | const auto file_buffer = ctx.ReadBuffer(); | 116 | const auto file_buffer = ctx.ReadBuffer(); |
| 117 | const std::string name = Common::StringFromBuffer(file_buffer); | 117 | const std::string name = Common::StringFromBuffer(file_buffer); |
| 118 | 118 | ||
| 119 | const auto mode = static_cast<FileSys::Mode>(rp.Pop<u32>()); | 119 | const auto mode = static_cast<FileSys::OpenMode>(rp.Pop<u32>()); |
| 120 | 120 | ||
| 121 | LOG_DEBUG(Service_FS, "called. file={}, mode={}", name, mode); | 121 | LOG_DEBUG(Service_FS, "called. file={}, mode={}", name, mode); |
| 122 | 122 | ||
| @@ -140,7 +140,7 @@ void IFileSystem::OpenDirectory(HLERequestContext& ctx) { | |||
| 140 | 140 | ||
| 141 | const auto file_buffer = ctx.ReadBuffer(); | 141 | const auto file_buffer = ctx.ReadBuffer(); |
| 142 | const std::string name = Common::StringFromBuffer(file_buffer); | 142 | const std::string name = Common::StringFromBuffer(file_buffer); |
| 143 | const auto mode = rp.PopRaw<OpenDirectoryMode>(); | 143 | const auto mode = rp.PopRaw<FileSys::OpenDirectoryMode>(); |
| 144 | 144 | ||
| 145 | LOG_DEBUG(Service_FS, "called. directory={}, mode={}", name, mode); | 145 | LOG_DEBUG(Service_FS, "called. directory={}, mode={}", name, mode); |
| 146 | 146 | ||
| @@ -165,7 +165,7 @@ void IFileSystem::GetEntryType(HLERequestContext& ctx) { | |||
| 165 | 165 | ||
| 166 | LOG_DEBUG(Service_FS, "called. file={}", name); | 166 | LOG_DEBUG(Service_FS, "called. file={}", name); |
| 167 | 167 | ||
| 168 | FileSys::EntryType vfs_entry_type{}; | 168 | FileSys::DirectoryEntryType vfs_entry_type{}; |
| 169 | auto result = backend.GetEntryType(&vfs_entry_type, name); | 169 | auto result = backend.GetEntryType(&vfs_entry_type, name); |
| 170 | if (result != ResultSuccess) { | 170 | if (result != ResultSuccess) { |
| 171 | IPC::ResponseBuilder rb{ctx, 2}; | 171 | IPC::ResponseBuilder rb{ctx, 2}; |
diff --git a/src/core/hle/service/filesystem/fsp/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp/fsp_srv.cpp index d04fb079f..c35df5530 100644 --- a/src/core/hle/service/filesystem/fsp/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp/fsp_srv.cpp | |||
| @@ -15,9 +15,9 @@ | |||
| 15 | #include "common/settings.h" | 15 | #include "common/settings.h" |
| 16 | #include "common/string_util.h" | 16 | #include "common/string_util.h" |
| 17 | #include "core/core.h" | 17 | #include "core/core.h" |
| 18 | #include "core/file_sys/directory.h" | ||
| 19 | #include "core/file_sys/errors.h" | 18 | #include "core/file_sys/errors.h" |
| 20 | #include "core/file_sys/mode.h" | 19 | #include "core/file_sys/fs_directory.h" |
| 20 | #include "core/file_sys/fs_filesystem.h" | ||
| 21 | #include "core/file_sys/nca_metadata.h" | 21 | #include "core/file_sys/nca_metadata.h" |
| 22 | #include "core/file_sys/patch_manager.h" | 22 | #include "core/file_sys/patch_manager.h" |
| 23 | #include "core/file_sys/romfs_factory.h" | 23 | #include "core/file_sys/romfs_factory.h" |
| @@ -52,8 +52,8 @@ public: | |||
| 52 | explicit ISaveDataInfoReader(Core::System& system_, | 52 | explicit ISaveDataInfoReader(Core::System& system_, |
| 53 | std::shared_ptr<SaveDataController> save_data_controller_, | 53 | std::shared_ptr<SaveDataController> save_data_controller_, |
| 54 | FileSys::SaveDataSpaceId space) | 54 | FileSys::SaveDataSpaceId space) |
| 55 | : ServiceFramework{system_, "ISaveDataInfoReader"}, | 55 | : ServiceFramework{system_, "ISaveDataInfoReader"}, save_data_controller{ |
| 56 | save_data_controller{save_data_controller_} { | 56 | save_data_controller_} { |
| 57 | static const FunctionInfo functions[] = { | 57 | static const FunctionInfo functions[] = { |
| 58 | {0, &ISaveDataInfoReader::ReadSaveDataInfo, "ReadSaveDataInfo"}, | 58 | {0, &ISaveDataInfoReader::ReadSaveDataInfo, "ReadSaveDataInfo"}, |
| 59 | }; | 59 | }; |
diff --git a/src/frontend_common/content_manager.h b/src/frontend_common/content_manager.h index 1cbaa73f7..fc359b494 100644 --- a/src/frontend_common/content_manager.h +++ b/src/frontend_common/content_manager.h | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include "core/core.h" | 9 | #include "core/core.h" |
| 10 | #include "core/file_sys/common_funcs.h" | 10 | #include "core/file_sys/common_funcs.h" |
| 11 | #include "core/file_sys/content_archive.h" | 11 | #include "core/file_sys/content_archive.h" |
| 12 | #include "core/file_sys/mode.h" | 12 | #include "core/file_sys/fs_filesystem.h" |
| 13 | #include "core/file_sys/nca_metadata.h" | 13 | #include "core/file_sys/nca_metadata.h" |
| 14 | #include "core/file_sys/patch_manager.h" | 14 | #include "core/file_sys/patch_manager.h" |
| 15 | #include "core/file_sys/registered_cache.h" | 15 | #include "core/file_sys/registered_cache.h" |
diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp index 9747e3fb3..0cbf5f45e 100644 --- a/src/yuzu/game_list_worker.cpp +++ b/src/yuzu/game_list_worker.cpp | |||
| @@ -17,7 +17,7 @@ | |||
| 17 | #include "core/file_sys/card_image.h" | 17 | #include "core/file_sys/card_image.h" |
| 18 | #include "core/file_sys/content_archive.h" | 18 | #include "core/file_sys/content_archive.h" |
| 19 | #include "core/file_sys/control_metadata.h" | 19 | #include "core/file_sys/control_metadata.h" |
| 20 | #include "core/file_sys/mode.h" | 20 | #include "core/file_sys/fs_filesystem.h" |
| 21 | #include "core/file_sys/nca_metadata.h" | 21 | #include "core/file_sys/nca_metadata.h" |
| 22 | #include "core/file_sys/patch_manager.h" | 22 | #include "core/file_sys/patch_manager.h" |
| 23 | #include "core/file_sys/registered_cache.h" | 23 | #include "core/file_sys/registered_cache.h" |
| @@ -347,7 +347,7 @@ void GameListWorker::ScanFileSystem(ScanTarget target, const std::string& dir_pa | |||
| 347 | 347 | ||
| 348 | if (!is_dir && | 348 | if (!is_dir && |
| 349 | (HasSupportedFileExtension(physical_name) || IsExtractedNCAMain(physical_name))) { | 349 | (HasSupportedFileExtension(physical_name) || IsExtractedNCAMain(physical_name))) { |
| 350 | const auto file = vfs->OpenFile(physical_name, FileSys::Mode::Read); | 350 | const auto file = vfs->OpenFile(physical_name, FileSys::OpenMode::Read); |
| 351 | if (!file) { | 351 | if (!file) { |
| 352 | return true; | 352 | return true; |
| 353 | } | 353 | } |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 38e2d096b..782bcbb61 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -56,7 +56,7 @@ | |||
| 56 | // These are wrappers to avoid the calls to CreateDirectory and CreateFile because of the Windows | 56 | // These are wrappers to avoid the calls to CreateDirectory and CreateFile because of the Windows |
| 57 | // defines. | 57 | // defines. |
| 58 | static FileSys::VirtualDir VfsFilesystemCreateDirectoryWrapper( | 58 | static FileSys::VirtualDir VfsFilesystemCreateDirectoryWrapper( |
| 59 | const FileSys::VirtualFilesystem& vfs, const std::string& path, FileSys::Mode mode) { | 59 | const FileSys::VirtualFilesystem& vfs, const std::string& path, FileSys::OpenMode mode) { |
| 60 | return vfs->CreateDirectory(path, mode); | 60 | return vfs->CreateDirectory(path, mode); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| @@ -1880,7 +1880,7 @@ bool GMainWindow::SelectAndSetCurrentUser( | |||
| 1880 | 1880 | ||
| 1881 | void GMainWindow::ConfigureFilesystemProvider(const std::string& filepath) { | 1881 | void GMainWindow::ConfigureFilesystemProvider(const std::string& filepath) { |
| 1882 | // Ensure all NCAs are registered before launching the game | 1882 | // Ensure all NCAs are registered before launching the game |
| 1883 | const auto file = vfs->OpenFile(filepath, FileSys::Mode::Read); | 1883 | const auto file = vfs->OpenFile(filepath, FileSys::OpenMode::Read); |
| 1884 | if (!file) { | 1884 | if (!file) { |
| 1885 | return; | 1885 | return; |
| 1886 | } | 1886 | } |
| @@ -2274,7 +2274,7 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target | |||
| 2274 | open_target = tr("Save Data"); | 2274 | open_target = tr("Save Data"); |
| 2275 | const auto nand_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir); | 2275 | const auto nand_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir); |
| 2276 | auto vfs_nand_dir = | 2276 | auto vfs_nand_dir = |
| 2277 | vfs->OpenDirectory(Common::FS::PathToUTF8String(nand_dir), FileSys::Mode::Read); | 2277 | vfs->OpenDirectory(Common::FS::PathToUTF8String(nand_dir), FileSys::OpenMode::Read); |
| 2278 | 2278 | ||
| 2279 | if (has_user_save) { | 2279 | if (has_user_save) { |
| 2280 | // User save data | 2280 | // User save data |
| @@ -2653,7 +2653,7 @@ void GMainWindow::RemoveCustomConfiguration(u64 program_id, const std::string& g | |||
| 2653 | void GMainWindow::RemoveCacheStorage(u64 program_id) { | 2653 | void GMainWindow::RemoveCacheStorage(u64 program_id) { |
| 2654 | const auto nand_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir); | 2654 | const auto nand_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir); |
| 2655 | auto vfs_nand_dir = | 2655 | auto vfs_nand_dir = |
| 2656 | vfs->OpenDirectory(Common::FS::PathToUTF8String(nand_dir), FileSys::Mode::Read); | 2656 | vfs->OpenDirectory(Common::FS::PathToUTF8String(nand_dir), FileSys::OpenMode::Read); |
| 2657 | 2657 | ||
| 2658 | const auto cache_storage_path = FileSys::SaveDataFactory::GetFullPath( | 2658 | const auto cache_storage_path = FileSys::SaveDataFactory::GetFullPath( |
| 2659 | {}, vfs_nand_dir, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::CacheStorage, | 2659 | {}, vfs_nand_dir, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::CacheStorage, |
| @@ -2673,7 +2673,8 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa | |||
| 2673 | "cancelled the operation.")); | 2673 | "cancelled the operation.")); |
| 2674 | }; | 2674 | }; |
| 2675 | 2675 | ||
| 2676 | const auto loader = Loader::GetLoader(*system, vfs->OpenFile(game_path, FileSys::Mode::Read)); | 2676 | const auto loader = |
| 2677 | Loader::GetLoader(*system, vfs->OpenFile(game_path, FileSys::OpenMode::Read)); | ||
| 2677 | if (loader == nullptr) { | 2678 | if (loader == nullptr) { |
| 2678 | failed(); | 2679 | failed(); |
| 2679 | return; | 2680 | return; |
| @@ -2717,7 +2718,7 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa | |||
| 2717 | const FileSys::PatchManager pm{title_id, system->GetFileSystemController(), installed}; | 2718 | const FileSys::PatchManager pm{title_id, system->GetFileSystemController(), installed}; |
| 2718 | auto romfs = pm.PatchRomFS(base_nca.get(), base_romfs, type, packed_update_raw, false); | 2719 | auto romfs = pm.PatchRomFS(base_nca.get(), base_romfs, type, packed_update_raw, false); |
| 2719 | 2720 | ||
| 2720 | const auto out = VfsFilesystemCreateDirectoryWrapper(vfs, path, FileSys::Mode::ReadWrite); | 2721 | const auto out = VfsFilesystemCreateDirectoryWrapper(vfs, path, FileSys::OpenMode::ReadWrite); |
| 2721 | 2722 | ||
| 2722 | if (out == nullptr) { | 2723 | if (out == nullptr) { |
| 2723 | failed(); | 2724 | failed(); |
| @@ -3015,7 +3016,7 @@ void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& ga | |||
| 3015 | system->GetContentProvider()}; | 3016 | system->GetContentProvider()}; |
| 3016 | const auto control = pm.GetControlMetadata(); | 3017 | const auto control = pm.GetControlMetadata(); |
| 3017 | const auto loader = | 3018 | const auto loader = |
| 3018 | Loader::GetLoader(*system, vfs->OpenFile(game_path, FileSys::Mode::Read)); | 3019 | Loader::GetLoader(*system, vfs->OpenFile(game_path, FileSys::OpenMode::Read)); |
| 3019 | game_title = fmt::format("{:016X}", program_id); | 3020 | game_title = fmt::format("{:016X}", program_id); |
| 3020 | if (control.first != nullptr) { | 3021 | if (control.first != nullptr) { |
| 3021 | game_title = control.first->GetApplicationName(); | 3022 | game_title = control.first->GetApplicationName(); |