mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-18 04:42:45 +01:00
fs: Replace Mode enum by OpenMode enum
This commit is contained in:
parent
0f9288e38d
commit
cc09c265e1
21 changed files with 195 additions and 188 deletions
|
@ -21,7 +21,7 @@
|
|||
#include "core/debugger/debugger.h"
|
||||
#include "core/device_memory.h"
|
||||
#include "core/file_sys/bis_factory.h"
|
||||
#include "core/file_sys/mode.h"
|
||||
#include "core/file_sys/fs_filesystem.h"
|
||||
#include "core/file_sys/patch_manager.h"
|
||||
#include "core/file_sys/registered_cache.h"
|
||||
#include "core/file_sys/romfs_factory.h"
|
||||
|
@ -102,7 +102,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::Mode::Read);
|
||||
const auto dir = vfs->OpenDirectory(dir_name, FileSys::OpenMode::Read);
|
||||
std::vector<FileSys::VirtualFile> concat;
|
||||
|
||||
for (u32 i = 0; i < 0x10; ++i) {
|
||||
|
@ -127,10 +127,10 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs,
|
|||
}
|
||||
|
||||
if (Common::FS::IsDir(path)) {
|
||||
return vfs->OpenFile(path + "/main", FileSys::Mode::Read);
|
||||
return vfs->OpenFile(path + "/main", FileSys::OpenMode::Read);
|
||||
}
|
||||
|
||||
return vfs->OpenFile(path, FileSys::Mode::Read);
|
||||
return vfs->OpenFile(path, FileSys::OpenMode::Read);
|
||||
}
|
||||
|
||||
struct System::Impl {
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include <fmt/format.h>
|
||||
#include "common/fs/path_util.h"
|
||||
#include "core/file_sys/bis_factory.h"
|
||||
#include "core/file_sys/mode.h"
|
||||
#include "core/file_sys/registered_cache.h"
|
||||
#include "core/file_sys/vfs/vfs.h"
|
||||
|
||||
|
@ -84,7 +83,7 @@ VirtualFile BISFactory::OpenPartitionStorage(BisPartitionId id,
|
|||
VirtualFilesystem file_system) const {
|
||||
auto& keys = Core::Crypto::KeyManager::Instance();
|
||||
Core::Crypto::PartitionDataManager pdm{file_system->OpenDirectory(
|
||||
Common::FS::GetYuzuPathString(Common::FS::YuzuPath::NANDDir), Mode::Read)};
|
||||
Common::FS::GetYuzuPathString(Common::FS::YuzuPath::NANDDir), OpenMode::Read)};
|
||||
keys.PopulateFromPartitionData(pdm);
|
||||
|
||||
switch (id) {
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// FileSys namespace
|
||||
|
||||
namespace FileSys {
|
||||
|
||||
enum class EntryType : u8 {
|
||||
Directory = 0,
|
||||
File = 1,
|
||||
};
|
||||
|
||||
// Structure of a directory entry, from
|
||||
// http://switchbrew.org/index.php?title=Filesystem_services#DirectoryEntry
|
||||
struct Entry {
|
||||
Entry(std::string_view view, EntryType entry_type, u64 entry_size)
|
||||
: type{entry_type}, file_size{entry_size} {
|
||||
const std::size_t copy_size = view.copy(filename, std::size(filename) - 1);
|
||||
filename[copy_size] = '\0';
|
||||
}
|
||||
|
||||
char filename[0x301];
|
||||
INSERT_PADDING_BYTES(3);
|
||||
EntryType type;
|
||||
INSERT_PADDING_BYTES(3);
|
||||
u64 file_size;
|
||||
};
|
||||
static_assert(sizeof(Entry) == 0x310, "Directory Entry struct isn't exactly 0x310 bytes long!");
|
||||
static_assert(offsetof(Entry, type) == 0x304, "Wrong offset for type in Entry.");
|
||||
static_assert(offsetof(Entry, file_size) == 0x308, "Wrong offset for file_size in Entry.");
|
||||
|
||||
} // namespace FileSys
|
33
src/core/file_sys/fs_directory.h
Normal file
33
src/core/file_sys/fs_directory.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace FileSys {
|
||||
|
||||
constexpr inline size_t EntryNameLengthMax = 0x300;
|
||||
|
||||
struct DirectoryEntry {
|
||||
DirectoryEntry(std::string_view view, s8 entry_type, u64 entry_size)
|
||||
: type{entry_type}, file_size{static_cast<s64>(entry_size)} {
|
||||
const std::size_t copy_size = view.copy(name, std::size(name) - 1);
|
||||
name[copy_size] = '\0';
|
||||
}
|
||||
|
||||
char name[EntryNameLengthMax + 1];
|
||||
INSERT_PADDING_BYTES(3);
|
||||
s8 type;
|
||||
INSERT_PADDING_BYTES(3);
|
||||
s64 file_size;
|
||||
};
|
||||
|
||||
static_assert(sizeof(DirectoryEntry) == 0x310,
|
||||
"Directory Entry struct isn't exactly 0x310 bytes long!");
|
||||
static_assert(offsetof(DirectoryEntry, type) == 0x304, "Wrong offset for type in Entry.");
|
||||
static_assert(offsetof(DirectoryEntry, file_size) == 0x308, "Wrong offset for file_size in Entry.");
|
||||
|
||||
struct DirectoryHandle {
|
||||
void* handle;
|
||||
};
|
||||
|
||||
} // namespace FileSys
|
39
src/core/file_sys/fs_filesystem.h
Normal file
39
src/core/file_sys/fs_filesystem.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace FileSys {
|
||||
|
||||
enum class OpenMode : u32 {
|
||||
Read = (1 << 0),
|
||||
Write = (1 << 1),
|
||||
AllowAppend = (1 << 2),
|
||||
|
||||
ReadWrite = (Read | Write),
|
||||
All = (ReadWrite | AllowAppend),
|
||||
};
|
||||
DECLARE_ENUM_FLAG_OPERATORS(OpenMode)
|
||||
|
||||
enum class OpenDirectoryMode : u64 {
|
||||
Directory = (1 << 0),
|
||||
File = (1 << 1),
|
||||
|
||||
All = (Directory | File),
|
||||
|
||||
/* TODO: Separate enum, like N? */
|
||||
_NotRequireFileSize = (1 << 31),
|
||||
};
|
||||
DECLARE_ENUM_FLAG_OPERATORS(OpenDirectoryMode)
|
||||
|
||||
enum class DirectoryEntryType : u8 {
|
||||
Directory = 0,
|
||||
File = 1,
|
||||
};
|
||||
|
||||
enum class CreateOption : u8 {
|
||||
None = (0 << 0),
|
||||
BigFile = (1 << 0),
|
||||
};
|
||||
|
||||
} // namespace FileSys
|
|
@ -1,23 +0,0 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
|
||||
namespace FileSys {
|
||||
|
||||
enum class Mode : u32 {
|
||||
Read = 1 << 0,
|
||||
Write = 1 << 1,
|
||||
ReadWrite = Read | Write,
|
||||
Append = 1 << 2,
|
||||
ReadAppend = Read | Append,
|
||||
WriteAppend = Write | Append,
|
||||
All = ReadWrite | Append,
|
||||
};
|
||||
|
||||
DECLARE_ENUM_FLAG_OPERATORS(Mode)
|
||||
|
||||
} // namespace FileSys
|
|
@ -5,7 +5,6 @@
|
|||
#include <numeric>
|
||||
#include <string>
|
||||
#include "common/fs/path_util.h"
|
||||
#include "core/file_sys/mode.h"
|
||||
#include "core/file_sys/vfs/vfs.h"
|
||||
|
||||
namespace FileSys {
|
||||
|
@ -36,12 +35,12 @@ VfsEntryType VfsFilesystem::GetEntryType(std::string_view path_) const {
|
|||
return VfsEntryType::None;
|
||||
}
|
||||
|
||||
VirtualFile VfsFilesystem::OpenFile(std::string_view path_, Mode perms) {
|
||||
VirtualFile VfsFilesystem::OpenFile(std::string_view path_, OpenMode perms) {
|
||||
const auto path = Common::FS::SanitizePath(path_);
|
||||
return root->GetFileRelative(path);
|
||||
}
|
||||
|
||||
VirtualFile VfsFilesystem::CreateFile(std::string_view path_, Mode perms) {
|
||||
VirtualFile VfsFilesystem::CreateFile(std::string_view path_, OpenMode perms) {
|
||||
const auto path = Common::FS::SanitizePath(path_);
|
||||
return root->CreateFileRelative(path);
|
||||
}
|
||||
|
@ -54,17 +53,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, Mode::ReadWrite);
|
||||
return OpenFile(new_path, OpenMode::ReadWrite);
|
||||
}
|
||||
|
||||
// Do it using RawCopy. Non-default impls are encouraged to optimize this.
|
||||
const auto old_file = OpenFile(old_path, Mode::Read);
|
||||
const auto old_file = OpenFile(old_path, OpenMode::Read);
|
||||
if (old_file == nullptr)
|
||||
return nullptr;
|
||||
auto new_file = OpenFile(new_path, Mode::Read);
|
||||
auto new_file = OpenFile(new_path, OpenMode::Read);
|
||||
if (new_file != nullptr)
|
||||
return nullptr;
|
||||
new_file = CreateFile(new_path, Mode::Write);
|
||||
new_file = CreateFile(new_path, OpenMode::Write);
|
||||
if (new_file == nullptr)
|
||||
return nullptr;
|
||||
if (!VfsRawCopy(old_file, new_file))
|
||||
|
@ -87,18 +86,18 @@ VirtualFile VfsFilesystem::MoveFile(std::string_view old_path, std::string_view
|
|||
|
||||
bool VfsFilesystem::DeleteFile(std::string_view path_) {
|
||||
const auto path = Common::FS::SanitizePath(path_);
|
||||
auto parent = OpenDirectory(Common::FS::GetParentPath(path), Mode::Write);
|
||||
auto parent = OpenDirectory(Common::FS::GetParentPath(path), OpenMode::Write);
|
||||
if (parent == nullptr)
|
||||
return false;
|
||||
return parent->DeleteFile(Common::FS::GetFilename(path));
|
||||
}
|
||||
|
||||
VirtualDir VfsFilesystem::OpenDirectory(std::string_view path_, Mode perms) {
|
||||
VirtualDir VfsFilesystem::OpenDirectory(std::string_view path_, OpenMode perms) {
|
||||
const auto path = Common::FS::SanitizePath(path_);
|
||||
return root->GetDirectoryRelative(path);
|
||||
}
|
||||
|
||||
VirtualDir VfsFilesystem::CreateDirectory(std::string_view path_, Mode perms) {
|
||||
VirtualDir VfsFilesystem::CreateDirectory(std::string_view path_, OpenMode perms) {
|
||||
const auto path = Common::FS::SanitizePath(path_);
|
||||
return root->CreateDirectoryRelative(path);
|
||||
}
|
||||
|
@ -108,13 +107,13 @@ 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, Mode::Read);
|
||||
auto old_dir = OpenDirectory(old_path, OpenMode::Read);
|
||||
if (old_dir == nullptr)
|
||||
return nullptr;
|
||||
auto new_dir = OpenDirectory(new_path, Mode::Read);
|
||||
auto new_dir = OpenDirectory(new_path, OpenMode::Read);
|
||||
if (new_dir != nullptr)
|
||||
return nullptr;
|
||||
new_dir = CreateDirectory(new_path, Mode::Write);
|
||||
new_dir = CreateDirectory(new_path, OpenMode::Write);
|
||||
if (new_dir == nullptr)
|
||||
return nullptr;
|
||||
|
||||
|
@ -149,7 +148,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), Mode::Write);
|
||||
auto parent = OpenDirectory(Common::FS::GetParentPath(path), OpenMode::Write);
|
||||
if (parent == nullptr)
|
||||
return false;
|
||||
return parent->DeleteSubdirectoryRecursive(Common::FS::GetFilename(path));
|
||||
|
|
|
@ -13,12 +13,11 @@
|
|||
|
||||
#include "common/common_funcs.h"
|
||||
#include "common/common_types.h"
|
||||
#include "core/file_sys/fs_filesystem.h"
|
||||
#include "core/file_sys/vfs/vfs_types.h"
|
||||
|
||||
namespace FileSys {
|
||||
|
||||
enum class Mode : u32;
|
||||
|
||||
// An enumeration representing what can be at the end of a path in a VfsFilesystem
|
||||
enum class VfsEntryType {
|
||||
None,
|
||||
|
@ -49,9 +48,9 @@ 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, Mode perms);
|
||||
virtual VirtualFile OpenFile(std::string_view path, OpenMode perms);
|
||||
// Creates a new, empty file at path
|
||||
virtual VirtualFile CreateFile(std::string_view path, Mode perms);
|
||||
virtual VirtualFile CreateFile(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);
|
||||
|
@ -62,9 +61,9 @@ public:
|
|||
virtual bool DeleteFile(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, Mode perms);
|
||||
virtual VirtualDir OpenDirectory(std::string_view path, OpenMode perms);
|
||||
// Creates a new, empty directory at path
|
||||
virtual VirtualDir CreateDirectory(std::string_view path, Mode perms);
|
||||
virtual VirtualDir CreateDirectory(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);
|
||||
|
|
|
@ -28,16 +28,14 @@ namespace {
|
|||
|
||||
constexpr size_t MaxOpenFiles = 512;
|
||||
|
||||
constexpr FS::FileAccessMode ModeFlagsToFileAccessMode(Mode mode) {
|
||||
constexpr FS::FileAccessMode ModeFlagsToFileAccessMode(OpenMode mode) {
|
||||
switch (mode) {
|
||||
case Mode::Read:
|
||||
case OpenMode::Read:
|
||||
return FS::FileAccessMode::Read;
|
||||
case Mode::Write:
|
||||
case Mode::ReadWrite:
|
||||
case Mode::Append:
|
||||
case Mode::ReadAppend:
|
||||
case Mode::WriteAppend:
|
||||
case Mode::All:
|
||||
case OpenMode::Write:
|
||||
case OpenMode::ReadWrite:
|
||||
case OpenMode::AllowAppend:
|
||||
case OpenMode::All:
|
||||
return FS::FileAccessMode::ReadWrite;
|
||||
default:
|
||||
return {};
|
||||
|
@ -74,7 +72,7 @@ VfsEntryType RealVfsFilesystem::GetEntryType(std::string_view path_) const {
|
|||
}
|
||||
|
||||
VirtualFile RealVfsFilesystem::OpenFileFromEntry(std::string_view path_, std::optional<u64> size,
|
||||
Mode perms) {
|
||||
OpenMode perms) {
|
||||
const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault);
|
||||
std::scoped_lock lk{list_lock};
|
||||
|
||||
|
@ -98,11 +96,11 @@ VirtualFile RealVfsFilesystem::OpenFileFromEntry(std::string_view path_, std::op
|
|||
return file;
|
||||
}
|
||||
|
||||
VirtualFile RealVfsFilesystem::OpenFile(std::string_view path_, Mode perms) {
|
||||
VirtualFile RealVfsFilesystem::OpenFile(std::string_view path_, OpenMode perms) {
|
||||
return OpenFileFromEntry(path_, {}, perms);
|
||||
}
|
||||
|
||||
VirtualFile RealVfsFilesystem::CreateFile(std::string_view path_, Mode perms) {
|
||||
VirtualFile RealVfsFilesystem::CreateFile(std::string_view path_, OpenMode perms) {
|
||||
const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault);
|
||||
{
|
||||
std::scoped_lock lk{list_lock};
|
||||
|
@ -145,7 +143,7 @@ VirtualFile RealVfsFilesystem::MoveFile(std::string_view old_path_, std::string_
|
|||
if (!FS::RenameFile(old_path, new_path)) {
|
||||
return nullptr;
|
||||
}
|
||||
return OpenFile(new_path, Mode::ReadWrite);
|
||||
return OpenFile(new_path, OpenMode::ReadWrite);
|
||||
}
|
||||
|
||||
bool RealVfsFilesystem::DeleteFile(std::string_view path_) {
|
||||
|
@ -157,12 +155,12 @@ bool RealVfsFilesystem::DeleteFile(std::string_view path_) {
|
|||
return FS::RemoveFile(path);
|
||||
}
|
||||
|
||||
VirtualDir RealVfsFilesystem::OpenDirectory(std::string_view path_, Mode perms) {
|
||||
VirtualDir RealVfsFilesystem::OpenDirectory(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_, Mode perms) {
|
||||
VirtualDir RealVfsFilesystem::CreateDirectory(std::string_view path_, OpenMode perms) {
|
||||
const auto path = FS::SanitizePath(path_, FS::DirectorySeparator::PlatformDefault);
|
||||
if (!FS::CreateDirs(path)) {
|
||||
return nullptr;
|
||||
|
@ -184,7 +182,7 @@ VirtualDir RealVfsFilesystem::MoveDirectory(std::string_view old_path_,
|
|||
if (!FS::RenameDir(old_path, new_path)) {
|
||||
return nullptr;
|
||||
}
|
||||
return OpenDirectory(new_path, Mode::ReadWrite);
|
||||
return OpenDirectory(new_path, OpenMode::ReadWrite);
|
||||
}
|
||||
|
||||
bool RealVfsFilesystem::DeleteDirectory(std::string_view path_) {
|
||||
|
@ -193,7 +191,7 @@ bool RealVfsFilesystem::DeleteDirectory(std::string_view path_) {
|
|||
}
|
||||
|
||||
std::unique_lock<std::mutex> RealVfsFilesystem::RefreshReference(const std::string& path,
|
||||
Mode perms,
|
||||
OpenMode perms,
|
||||
FileReference& reference) {
|
||||
std::unique_lock lk{list_lock};
|
||||
|
||||
|
@ -266,7 +264,7 @@ void RealVfsFilesystem::RemoveReferenceFromListLocked(FileReference& reference)
|
|||
}
|
||||
|
||||
RealVfsFile::RealVfsFile(RealVfsFilesystem& base_, std::unique_ptr<FileReference> reference_,
|
||||
const std::string& path_, Mode perms_, std::optional<u64> size_)
|
||||
const std::string& path_, OpenMode perms_, std::optional<u64> size_)
|
||||
: base(base_), reference(std::move(reference_)), path(path_),
|
||||
parent_path(FS::GetParentPath(path_)), path_components(FS::SplitPathComponentsCopy(path_)),
|
||||
size(size_), perms(perms_) {}
|
||||
|
@ -298,11 +296,11 @@ VirtualDir RealVfsFile::GetContainingDirectory() const {
|
|||
}
|
||||
|
||||
bool RealVfsFile::IsWritable() const {
|
||||
return True(perms & Mode::Write);
|
||||
return True(perms & OpenMode::Write);
|
||||
}
|
||||
|
||||
bool RealVfsFile::IsReadable() const {
|
||||
return True(perms & Mode::Read);
|
||||
return True(perms & OpenMode::Read);
|
||||
}
|
||||
|
||||
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) {
|
|||
|
||||
template <>
|
||||
std::vector<VirtualFile> RealVfsDirectory::IterateEntries<RealVfsFile, VfsFile>() const {
|
||||
if (perms == Mode::Append) {
|
||||
if (perms == OpenMode::AllowAppend) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -353,7 +351,7 @@ std::vector<VirtualFile> RealVfsDirectory::IterateEntries<RealVfsFile, VfsFile>(
|
|||
|
||||
template <>
|
||||
std::vector<VirtualDir> RealVfsDirectory::IterateEntries<RealVfsDirectory, VfsDirectory>() const {
|
||||
if (perms == Mode::Append) {
|
||||
if (perms == OpenMode::AllowAppend) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -373,10 +371,11 @@ std::vector<VirtualDir> RealVfsDirectory::IterateEntries<RealVfsDirectory, VfsDi
|
|||
return out;
|
||||
}
|
||||
|
||||
RealVfsDirectory::RealVfsDirectory(RealVfsFilesystem& base_, const std::string& path_, Mode perms_)
|
||||
RealVfsDirectory::RealVfsDirectory(RealVfsFilesystem& base_, const std::string& path_,
|
||||
OpenMode perms_)
|
||||
: base(base_), path(FS::RemoveTrailingSlash(path_)), parent_path(FS::GetParentPath(path)),
|
||||
path_components(FS::SplitPathComponentsCopy(path)), perms(perms_) {
|
||||
if (!FS::Exists(path) && True(perms & Mode::Write)) {
|
||||
if (!FS::Exists(path) && True(perms & OpenMode::Write)) {
|
||||
void(FS::CreateDirs(path));
|
||||
}
|
||||
}
|
||||
|
@ -456,11 +455,11 @@ std::vector<VirtualDir> RealVfsDirectory::GetSubdirectories() const {
|
|||
}
|
||||
|
||||
bool RealVfsDirectory::IsWritable() const {
|
||||
return True(perms & Mode::Write);
|
||||
return True(perms & OpenMode::Write);
|
||||
}
|
||||
|
||||
bool RealVfsDirectory::IsReadable() const {
|
||||
return True(perms & Mode::Read);
|
||||
return True(perms & OpenMode::Read);
|
||||
}
|
||||
|
||||
std::string RealVfsDirectory::GetName() const {
|
||||
|
@ -507,7 +506,7 @@ std::string RealVfsDirectory::GetFullPath() const {
|
|||
}
|
||||
|
||||
std::map<std::string, VfsEntryType, std::less<>> RealVfsDirectory::GetEntries() const {
|
||||
if (perms == Mode::Append) {
|
||||
if (perms == OpenMode::AllowAppend) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <optional>
|
||||
#include <string_view>
|
||||
#include "common/intrusive_list.h"
|
||||
#include "core/file_sys/mode.h"
|
||||
#include "core/file_sys/fs_filesystem.h"
|
||||
#include "core/file_sys/vfs/vfs.h"
|
||||
|
||||
namespace Common::FS {
|
||||
|
@ -33,13 +33,14 @@ public:
|
|||
bool IsReadable() const override;
|
||||
bool IsWritable() const override;
|
||||
VfsEntryType GetEntryType(std::string_view path) const override;
|
||||
VirtualFile OpenFile(std::string_view path, Mode perms = Mode::Read) override;
|
||||
VirtualFile CreateFile(std::string_view path, Mode perms = Mode::ReadWrite) 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, Mode perms = Mode::Read) override;
|
||||
VirtualDir CreateDirectory(std::string_view path, Mode perms = Mode::ReadWrite) override;
|
||||
VirtualDir OpenDirectory(std::string_view path, OpenMode perms = OpenMode::Read) override;
|
||||
VirtualDir CreateDirectory(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;
|
||||
bool DeleteDirectory(std::string_view path) override;
|
||||
|
@ -54,14 +55,14 @@ private:
|
|||
|
||||
private:
|
||||
friend class RealVfsFile;
|
||||
std::unique_lock<std::mutex> RefreshReference(const std::string& path, Mode perms,
|
||||
std::unique_lock<std::mutex> RefreshReference(const std::string& path, OpenMode perms,
|
||||
FileReference& reference);
|
||||
void DropReference(std::unique_ptr<FileReference>&& reference);
|
||||
|
||||
private:
|
||||
friend class RealVfsDirectory;
|
||||
VirtualFile OpenFileFromEntry(std::string_view path, std::optional<u64> size,
|
||||
Mode perms = Mode::Read);
|
||||
OpenMode perms = OpenMode::Read);
|
||||
|
||||
private:
|
||||
void EvictSingleReferenceLocked();
|
||||
|
@ -89,7 +90,8 @@ public:
|
|||
|
||||
private:
|
||||
RealVfsFile(RealVfsFilesystem& base, std::unique_ptr<FileReference> reference,
|
||||
const std::string& path, Mode perms = Mode::Read, std::optional<u64> size = {});
|
||||
const std::string& path, OpenMode perms = OpenMode::Read,
|
||||
std::optional<u64> size = {});
|
||||
|
||||
RealVfsFilesystem& base;
|
||||
std::unique_ptr<FileReference> reference;
|
||||
|
@ -97,7 +99,7 @@ private:
|
|||
std::string parent_path;
|
||||
std::vector<std::string> path_components;
|
||||
std::optional<u64> size;
|
||||
Mode perms;
|
||||
OpenMode perms;
|
||||
};
|
||||
|
||||
// An implementation of VfsDirectory that represents a directory on the user's computer.
|
||||
|
@ -130,7 +132,8 @@ public:
|
|||
std::map<std::string, VfsEntryType, std::less<>> GetEntries() const override;
|
||||
|
||||
private:
|
||||
RealVfsDirectory(RealVfsFilesystem& base, const std::string& path, Mode perms = Mode::Read);
|
||||
RealVfsDirectory(RealVfsFilesystem& base, const std::string& path,
|
||||
OpenMode perms = OpenMode::Read);
|
||||
|
||||
template <typename T, typename R>
|
||||
std::vector<std::shared_ptr<R>> IterateEntries() const;
|
||||
|
@ -139,7 +142,7 @@ private:
|
|||
std::string path;
|
||||
std::string parent_path;
|
||||
std::vector<std::string> path_components;
|
||||
Mode perms;
|
||||
OpenMode perms;
|
||||
};
|
||||
|
||||
} // namespace FileSys
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "common/string_util.h"
|
||||
#include "core/core.h"
|
||||
#include "core/file_sys/content_archive.h"
|
||||
#include "core/file_sys/mode.h"
|
||||
#include "core/file_sys/fs_filesystem.h"
|
||||
#include "core/file_sys/nca_metadata.h"
|
||||
#include "core/file_sys/patch_manager.h"
|
||||
#include "core/file_sys/registered_cache.h"
|
||||
|
@ -213,7 +213,7 @@ void ExtractSharedFonts(Core::System& system) {
|
|||
std::move(decrypted_data), DECRYPTED_SHARED_FONTS[i]);
|
||||
|
||||
const auto temp_dir = system.GetFilesystem()->CreateDirectory(
|
||||
Common::FS::PathToUTF8String(fonts_dir), FileSys::Mode::ReadWrite);
|
||||
Common::FS::PathToUTF8String(fonts_dir), FileSys::OpenMode::ReadWrite);
|
||||
|
||||
const auto out_file = temp_dir->CreateFile(DECRYPTED_SHARED_FONTS[i]);
|
||||
|
||||
|
@ -333,7 +333,7 @@ void WebBrowser::ExtractOfflineRomFS() {
|
|||
const auto extracted_romfs_dir = FileSys::ExtractRomFS(offline_romfs);
|
||||
|
||||
const auto temp_dir = system.GetFilesystem()->CreateDirectory(
|
||||
Common::FS::PathToUTF8String(offline_cache_dir), FileSys::Mode::ReadWrite);
|
||||
Common::FS::PathToUTF8String(offline_cache_dir), FileSys::OpenMode::ReadWrite);
|
||||
|
||||
FileSys::VfsRawCopyD(extracted_romfs_dir, temp_dir);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "core/file_sys/card_image.h"
|
||||
#include "core/file_sys/control_metadata.h"
|
||||
#include "core/file_sys/errors.h"
|
||||
#include "core/file_sys/mode.h"
|
||||
#include "core/file_sys/patch_manager.h"
|
||||
#include "core/file_sys/registered_cache.h"
|
||||
#include "core/file_sys/romfs_factory.h"
|
||||
|
@ -56,7 +55,7 @@ Result VfsDirectoryServiceWrapper::CreateFile(const std::string& path_, u64 size
|
|||
return FileSys::ERROR_PATH_NOT_FOUND;
|
||||
}
|
||||
|
||||
FileSys::EntryType entry_type{};
|
||||
FileSys::DirectoryEntryType entry_type{};
|
||||
if (GetEntryType(&entry_type, path) == ResultSuccess) {
|
||||
return FileSys::ERROR_PATH_ALREADY_EXISTS;
|
||||
}
|
||||
|
@ -214,7 +213,8 @@ Result VfsDirectoryServiceWrapper::RenameDirectory(const std::string& src_path_,
|
|||
}
|
||||
|
||||
Result VfsDirectoryServiceWrapper::OpenFile(FileSys::VirtualFile* out_file,
|
||||
const std::string& path_, FileSys::Mode mode) const {
|
||||
const std::string& path_,
|
||||
FileSys::OpenMode mode) const {
|
||||
const std::string path(Common::FS::SanitizePath(path_));
|
||||
std::string_view npath = path;
|
||||
while (!npath.empty() && (npath[0] == '/' || npath[0] == '\\')) {
|
||||
|
@ -226,7 +226,7 @@ Result VfsDirectoryServiceWrapper::OpenFile(FileSys::VirtualFile* out_file,
|
|||
return FileSys::ERROR_PATH_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (mode == FileSys::Mode::Append) {
|
||||
if (mode == FileSys::OpenMode::AllowAppend) {
|
||||
*out_file = std::make_shared<FileSys::OffsetVfsFile>(file, 0, file->GetSize());
|
||||
} else {
|
||||
*out_file = file;
|
||||
|
@ -247,7 +247,7 @@ Result VfsDirectoryServiceWrapper::OpenDirectory(FileSys::VirtualDir* out_direct
|
|||
return ResultSuccess;
|
||||
}
|
||||
|
||||
Result VfsDirectoryServiceWrapper::GetEntryType(FileSys::EntryType* out_entry_type,
|
||||
Result VfsDirectoryServiceWrapper::GetEntryType(FileSys::DirectoryEntryType* out_entry_type,
|
||||
const std::string& path_) const {
|
||||
std::string path(Common::FS::SanitizePath(path_));
|
||||
auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path));
|
||||
|
@ -258,17 +258,17 @@ Result VfsDirectoryServiceWrapper::GetEntryType(FileSys::EntryType* out_entry_ty
|
|||
auto filename = Common::FS::GetFilename(path);
|
||||
// TODO(Subv): Some games use the '/' path, find out what this means.
|
||||
if (filename.empty()) {
|
||||
*out_entry_type = FileSys::EntryType::Directory;
|
||||
*out_entry_type = FileSys::DirectoryEntryType::Directory;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
if (dir->GetFile(filename) != nullptr) {
|
||||
*out_entry_type = FileSys::EntryType::File;
|
||||
*out_entry_type = FileSys::DirectoryEntryType::File;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
if (dir->GetSubdirectory(filename) != nullptr) {
|
||||
*out_entry_type = FileSys::EntryType::Directory;
|
||||
*out_entry_type = FileSys::DirectoryEntryType::Directory;
|
||||
return ResultSuccess;
|
||||
}
|
||||
|
||||
|
@ -282,7 +282,7 @@ Result VfsDirectoryServiceWrapper::GetFileTimeStampRaw(
|
|||
return FileSys::ERROR_PATH_NOT_FOUND;
|
||||
}
|
||||
|
||||
FileSys::EntryType entry_type;
|
||||
FileSys::DirectoryEntryType entry_type;
|
||||
if (GetEntryType(&entry_type, path) != ResultSuccess) {
|
||||
return FileSys::ERROR_PATH_NOT_FOUND;
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ std::shared_ptr<SaveDataController> FileSystemController::OpenSaveDataController
|
|||
std::shared_ptr<FileSys::SaveDataFactory> FileSystemController::CreateSaveDataFactory(
|
||||
ProgramId program_id) {
|
||||
using YuzuPath = Common::FS::YuzuPath;
|
||||
const auto rw_mode = FileSys::Mode::ReadWrite;
|
||||
const auto rw_mode = FileSys::OpenMode::ReadWrite;
|
||||
|
||||
auto vfs = system.GetFilesystem();
|
||||
const auto nand_directory =
|
||||
|
@ -686,15 +686,15 @@ void FileSystemController::CreateFactories(FileSys::VfsFilesystem& vfs, bool ove
|
|||
using YuzuPath = Common::FS::YuzuPath;
|
||||
const auto sdmc_dir_path = Common::FS::GetYuzuPath(YuzuPath::SDMCDir);
|
||||
const auto sdmc_load_dir_path = sdmc_dir_path / "atmosphere/contents";
|
||||
const auto rw_mode = FileSys::Mode::ReadWrite;
|
||||
const auto rw_mode = FileSys::OpenMode::ReadWrite;
|
||||
|
||||
auto nand_directory =
|
||||
vfs.OpenDirectory(Common::FS::GetYuzuPathString(YuzuPath::NANDDir), rw_mode);
|
||||
auto sd_directory = vfs.OpenDirectory(Common::FS::PathToUTF8String(sdmc_dir_path), rw_mode);
|
||||
auto load_directory =
|
||||
vfs.OpenDirectory(Common::FS::GetYuzuPathString(YuzuPath::LoadDir), FileSys::Mode::Read);
|
||||
auto sd_load_directory =
|
||||
vfs.OpenDirectory(Common::FS::PathToUTF8String(sdmc_load_dir_path), FileSys::Mode::Read);
|
||||
auto load_directory = vfs.OpenDirectory(Common::FS::GetYuzuPathString(YuzuPath::LoadDir),
|
||||
FileSys::OpenMode::Read);
|
||||
auto sd_load_directory = vfs.OpenDirectory(Common::FS::PathToUTF8String(sdmc_load_dir_path),
|
||||
FileSys::OpenMode::Read);
|
||||
auto dump_directory =
|
||||
vfs.OpenDirectory(Common::FS::GetYuzuPathString(YuzuPath::DumpDir), rw_mode);
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
|
||||
#include <memory>
|
||||
#include "common/common_types.h"
|
||||
#include "core/file_sys/directory.h"
|
||||
#include "core/file_sys/fs_directory.h"
|
||||
#include "core/file_sys/fs_filesystem.h"
|
||||
#include "core/file_sys/vfs/vfs.h"
|
||||
#include "core/hle/result.h"
|
||||
|
||||
|
@ -26,7 +27,6 @@ class XCI;
|
|||
|
||||
enum class BisPartitionId : u32;
|
||||
enum class ContentRecordType : u8;
|
||||
enum class Mode : u32;
|
||||
enum class SaveDataSpaceId : u8;
|
||||
enum class SaveDataType : u8;
|
||||
enum class StorageId : u8;
|
||||
|
@ -57,13 +57,6 @@ enum class ImageDirectoryId : u32 {
|
|||
SdCard,
|
||||
};
|
||||
|
||||
enum class OpenDirectoryMode : u64 {
|
||||
Directory = (1 << 0),
|
||||
File = (1 << 1),
|
||||
All = Directory | File
|
||||
};
|
||||
DECLARE_ENUM_FLAG_OPERATORS(OpenDirectoryMode);
|
||||
|
||||
using ProcessId = u64;
|
||||
using ProgramId = u64;
|
||||
|
||||
|
@ -237,7 +230,7 @@ public:
|
|||
* @return Opened file, or error code
|
||||
*/
|
||||
Result OpenFile(FileSys::VirtualFile* out_file, const std::string& path,
|
||||
FileSys::Mode mode) const;
|
||||
FileSys::OpenMode mode) const;
|
||||
|
||||
/**
|
||||
* Open a directory specified by its path
|
||||
|
@ -250,7 +243,7 @@ public:
|
|||
* Get the type of the specified path
|
||||
* @return The type of the specified path or error code
|
||||
*/
|
||||
Result GetEntryType(FileSys::EntryType* out_entry_type, const std::string& path) const;
|
||||
Result GetEntryType(FileSys::DirectoryEntryType* out_entry_type, const std::string& path) const;
|
||||
|
||||
/**
|
||||
* Get the timestamp of the specified path
|
||||
|
|
|
@ -8,23 +8,26 @@
|
|||
namespace Service::FileSystem {
|
||||
|
||||
template <typename T>
|
||||
static void BuildEntryIndex(std::vector<FileSys::Entry>& entries, const std::vector<T>& new_data,
|
||||
FileSys::EntryType type) {
|
||||
static void BuildEntryIndex(std::vector<FileSys::DirectoryEntry>& entries,
|
||||
const std::vector<T>& new_data, FileSys::DirectoryEntryType type) {
|
||||
entries.reserve(entries.size() + new_data.size());
|
||||
|
||||
for (const auto& new_entry : new_data) {
|
||||
auto name = new_entry->GetName();
|
||||
|
||||
if (type == FileSys::EntryType::File && name == FileSys::GetSaveDataSizeFileName()) {
|
||||
if (type == FileSys::DirectoryEntryType::File &&
|
||||
name == FileSys::GetSaveDataSizeFileName()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
entries.emplace_back(name, type,
|
||||
type == FileSys::EntryType::Directory ? 0 : new_entry->GetSize());
|
||||
entries.emplace_back(name, static_cast<s8>(type),
|
||||
type == FileSys::DirectoryEntryType::Directory ? 0
|
||||
: new_entry->GetSize());
|
||||
}
|
||||
}
|
||||
|
||||
IDirectory::IDirectory(Core::System& system_, FileSys::VirtualDir backend_, OpenDirectoryMode mode)
|
||||
IDirectory::IDirectory(Core::System& system_, FileSys::VirtualDir backend_,
|
||||
FileSys::OpenDirectoryMode mode)
|
||||
: ServiceFramework{system_, "IDirectory"}, backend(std::move(backend_)) {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &IDirectory::Read, "Read"},
|
||||
|
@ -34,11 +37,12 @@ IDirectory::IDirectory(Core::System& system_, FileSys::VirtualDir backend_, Open
|
|||
|
||||
// TODO(DarkLordZach): Verify that this is the correct behavior.
|
||||
// Build entry index now to save time later.
|
||||
if (True(mode & OpenDirectoryMode::Directory)) {
|
||||
BuildEntryIndex(entries, backend->GetSubdirectories(), FileSys::EntryType::Directory);
|
||||
if (True(mode & FileSys::OpenDirectoryMode::Directory)) {
|
||||
BuildEntryIndex(entries, backend->GetSubdirectories(),
|
||||
FileSys::DirectoryEntryType::Directory);
|
||||
}
|
||||
if (True(mode & OpenDirectoryMode::File)) {
|
||||
BuildEntryIndex(entries, backend->GetFiles(), FileSys::EntryType::File);
|
||||
if (True(mode & FileSys::OpenDirectoryMode::File)) {
|
||||
BuildEntryIndex(entries, backend->GetFiles(), FileSys::DirectoryEntryType::File);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,7 +50,7 @@ void IDirectory::Read(HLERequestContext& ctx) {
|
|||
LOG_DEBUG(Service_FS, "called.");
|
||||
|
||||
// Calculate how many entries we can fit in the output buffer
|
||||
const u64 count_entries = ctx.GetWriteBufferNumElements<FileSys::Entry>();
|
||||
const u64 count_entries = ctx.GetWriteBufferNumElements<FileSys::DirectoryEntry>();
|
||||
|
||||
// Cap at total number of entries.
|
||||
const u64 actual_entries = std::min(count_entries, entries.size() - next_entry_index);
|
||||
|
|
|
@ -3,9 +3,10 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "core/file_sys/fs_filesystem.h"
|
||||
#include "core/file_sys/vfs/vfs.h"
|
||||
#include "core/hle/service/filesystem/filesystem.h"
|
||||
#include "core/hle/service/filesystem/fsp_util.h"
|
||||
#include "core/hle/service/filesystem/fsp/fsp_util.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Service::FileSystem {
|
||||
|
@ -13,11 +14,11 @@ namespace Service::FileSystem {
|
|||
class IDirectory final : public ServiceFramework<IDirectory> {
|
||||
public:
|
||||
explicit IDirectory(Core::System& system_, FileSys::VirtualDir backend_,
|
||||
OpenDirectoryMode mode);
|
||||
FileSys::OpenDirectoryMode mode);
|
||||
|
||||
private:
|
||||
FileSys::VirtualDir backend;
|
||||
std::vector<FileSys::Entry> entries;
|
||||
std::vector<FileSys::DirectoryEntry> entries;
|
||||
u64 next_entry_index = 0;
|
||||
|
||||
void Read(HLERequestContext& ctx);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "core/file_sys/vfs.h"
|
||||
#include "core/hle/service/filesystem/filesystem.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
namespace Service::FileSystem {
|
||||
|
||||
IFileSystem::IFileSystem(Core::System& system_, FileSys::VirtualDir backend_, SizeGetter size_)
|
||||
: ServiceFramework{system_, "IFileSystem"}, backend{std::move(backend_)},
|
||||
size{std::move(size_)} {
|
||||
: ServiceFramework{system_, "IFileSystem"}, backend{std::move(backend_)}, size{std::move(
|
||||
size_)} {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &IFileSystem::CreateFile, "CreateFile"},
|
||||
{1, &IFileSystem::DeleteFile, "DeleteFile"},
|
||||
|
@ -116,7 +116,7 @@ void IFileSystem::OpenFile(HLERequestContext& ctx) {
|
|||
const auto file_buffer = ctx.ReadBuffer();
|
||||
const std::string name = Common::StringFromBuffer(file_buffer);
|
||||
|
||||
const auto mode = static_cast<FileSys::Mode>(rp.Pop<u32>());
|
||||
const auto mode = static_cast<FileSys::OpenMode>(rp.Pop<u32>());
|
||||
|
||||
LOG_DEBUG(Service_FS, "called. file={}, mode={}", name, mode);
|
||||
|
||||
|
@ -140,7 +140,7 @@ void IFileSystem::OpenDirectory(HLERequestContext& ctx) {
|
|||
|
||||
const auto file_buffer = ctx.ReadBuffer();
|
||||
const std::string name = Common::StringFromBuffer(file_buffer);
|
||||
const auto mode = rp.PopRaw<OpenDirectoryMode>();
|
||||
const auto mode = rp.PopRaw<FileSys::OpenDirectoryMode>();
|
||||
|
||||
LOG_DEBUG(Service_FS, "called. directory={}, mode={}", name, mode);
|
||||
|
||||
|
@ -165,7 +165,7 @@ void IFileSystem::GetEntryType(HLERequestContext& ctx) {
|
|||
|
||||
LOG_DEBUG(Service_FS, "called. file={}", name);
|
||||
|
||||
FileSys::EntryType vfs_entry_type{};
|
||||
FileSys::DirectoryEntryType vfs_entry_type{};
|
||||
auto result = backend.GetEntryType(&vfs_entry_type, name);
|
||||
if (result != ResultSuccess) {
|
||||
IPC::ResponseBuilder rb{ctx, 2};
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
#include "common/settings.h"
|
||||
#include "common/string_util.h"
|
||||
#include "core/core.h"
|
||||
#include "core/file_sys/directory.h"
|
||||
#include "core/file_sys/errors.h"
|
||||
#include "core/file_sys/mode.h"
|
||||
#include "core/file_sys/fs_directory.h"
|
||||
#include "core/file_sys/fs_filesystem.h"
|
||||
#include "core/file_sys/nca_metadata.h"
|
||||
#include "core/file_sys/patch_manager.h"
|
||||
#include "core/file_sys/romfs_factory.h"
|
||||
|
@ -52,8 +52,8 @@ public:
|
|||
explicit ISaveDataInfoReader(Core::System& system_,
|
||||
std::shared_ptr<SaveDataController> save_data_controller_,
|
||||
FileSys::SaveDataSpaceId space)
|
||||
: ServiceFramework{system_, "ISaveDataInfoReader"},
|
||||
save_data_controller{save_data_controller_} {
|
||||
: ServiceFramework{system_, "ISaveDataInfoReader"}, save_data_controller{
|
||||
save_data_controller_} {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &ISaveDataInfoReader::ReadSaveDataInfo, "ReadSaveDataInfo"},
|
||||
};
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include "core/core.h"
|
||||
#include "core/file_sys/common_funcs.h"
|
||||
#include "core/file_sys/content_archive.h"
|
||||
#include "core/file_sys/mode.h"
|
||||
#include "core/file_sys/fs_filesystem.h"
|
||||
#include "core/file_sys/nca_metadata.h"
|
||||
#include "core/file_sys/patch_manager.h"
|
||||
#include "core/file_sys/registered_cache.h"
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "core/file_sys/card_image.h"
|
||||
#include "core/file_sys/content_archive.h"
|
||||
#include "core/file_sys/control_metadata.h"
|
||||
#include "core/file_sys/mode.h"
|
||||
#include "core/file_sys/fs_filesystem.h"
|
||||
#include "core/file_sys/nca_metadata.h"
|
||||
#include "core/file_sys/patch_manager.h"
|
||||
#include "core/file_sys/registered_cache.h"
|
||||
|
@ -347,7 +347,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::Mode::Read);
|
||||
const auto file = vfs->OpenFile(physical_name, FileSys::OpenMode::Read);
|
||||
if (!file) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
// These are wrappers to avoid the calls to CreateDirectory and CreateFile because of the Windows
|
||||
// defines.
|
||||
static FileSys::VirtualDir VfsFilesystemCreateDirectoryWrapper(
|
||||
const FileSys::VirtualFilesystem& vfs, const std::string& path, FileSys::Mode mode) {
|
||||
const FileSys::VirtualFilesystem& vfs, const std::string& path, FileSys::OpenMode mode) {
|
||||
return vfs->CreateDirectory(path, mode);
|
||||
}
|
||||
|
||||
|
@ -1880,7 +1880,7 @@ bool GMainWindow::SelectAndSetCurrentUser(
|
|||
|
||||
void GMainWindow::ConfigureFilesystemProvider(const std::string& filepath) {
|
||||
// Ensure all NCAs are registered before launching the game
|
||||
const auto file = vfs->OpenFile(filepath, FileSys::Mode::Read);
|
||||
const auto file = vfs->OpenFile(filepath, FileSys::OpenMode::Read);
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
|
@ -2274,7 +2274,7 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target
|
|||
open_target = tr("Save Data");
|
||||
const auto nand_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir);
|
||||
auto vfs_nand_dir =
|
||||
vfs->OpenDirectory(Common::FS::PathToUTF8String(nand_dir), FileSys::Mode::Read);
|
||||
vfs->OpenDirectory(Common::FS::PathToUTF8String(nand_dir), FileSys::OpenMode::Read);
|
||||
|
||||
if (has_user_save) {
|
||||
// User save data
|
||||
|
@ -2653,7 +2653,7 @@ void GMainWindow::RemoveCustomConfiguration(u64 program_id, const std::string& g
|
|||
void GMainWindow::RemoveCacheStorage(u64 program_id) {
|
||||
const auto nand_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::NANDDir);
|
||||
auto vfs_nand_dir =
|
||||
vfs->OpenDirectory(Common::FS::PathToUTF8String(nand_dir), FileSys::Mode::Read);
|
||||
vfs->OpenDirectory(Common::FS::PathToUTF8String(nand_dir), FileSys::OpenMode::Read);
|
||||
|
||||
const auto cache_storage_path = FileSys::SaveDataFactory::GetFullPath(
|
||||
{}, vfs_nand_dir, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::CacheStorage,
|
||||
|
@ -2673,7 +2673,8 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa
|
|||
"cancelled the operation."));
|
||||
};
|
||||
|
||||
const auto loader = Loader::GetLoader(*system, vfs->OpenFile(game_path, FileSys::Mode::Read));
|
||||
const auto loader =
|
||||
Loader::GetLoader(*system, vfs->OpenFile(game_path, FileSys::OpenMode::Read));
|
||||
if (loader == nullptr) {
|
||||
failed();
|
||||
return;
|
||||
|
@ -2717,7 +2718,7 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa
|
|||
const FileSys::PatchManager pm{title_id, system->GetFileSystemController(), installed};
|
||||
auto romfs = pm.PatchRomFS(base_nca.get(), base_romfs, type, packed_update_raw, false);
|
||||
|
||||
const auto out = VfsFilesystemCreateDirectoryWrapper(vfs, path, FileSys::Mode::ReadWrite);
|
||||
const auto out = VfsFilesystemCreateDirectoryWrapper(vfs, path, FileSys::OpenMode::ReadWrite);
|
||||
|
||||
if (out == nullptr) {
|
||||
failed();
|
||||
|
@ -3015,7 +3016,7 @@ void GMainWindow::OnGameListCreateShortcut(u64 program_id, const std::string& ga
|
|||
system->GetContentProvider()};
|
||||
const auto control = pm.GetControlMetadata();
|
||||
const auto loader =
|
||||
Loader::GetLoader(*system, vfs->OpenFile(game_path, FileSys::Mode::Read));
|
||||
Loader::GetLoader(*system, vfs->OpenFile(game_path, FileSys::OpenMode::Read));
|
||||
game_title = fmt::format("{:016X}", program_id);
|
||||
if (control.first != nullptr) {
|
||||
game_title = control.first->GetApplicationName();
|
||||
|
|
Loading…
Reference in a new issue