summaryrefslogtreecommitdiffstats
path: root/src/core/hle
diff options
context:
space:
mode:
authorFearlessTobi <thm.frey@gmail.com>2024-01-18 21:31:41 +0100
committerLiam <byteslice@airmail.cc>2024-01-25 22:42:05 +0100
commitcc09c265e15e9598844482a8b5a22b12650b3f1b (patch)
treeefca7a933c1a599e04a0201e1657717d755a3248 /src/core/hle
parentvfs: Move vfs files to their own directory (diff)
downloadyuzu-cc09c265e15e9598844482a8b5a22b12650b3f1b.tar
yuzu-cc09c265e15e9598844482a8b5a22b12650b3f1b.tar.gz
yuzu-cc09c265e15e9598844482a8b5a22b12650b3f1b.tar.bz2
yuzu-cc09c265e15e9598844482a8b5a22b12650b3f1b.tar.lz
yuzu-cc09c265e15e9598844482a8b5a22b12650b3f1b.tar.xz
yuzu-cc09c265e15e9598844482a8b5a22b12650b3f1b.tar.zst
yuzu-cc09c265e15e9598844482a8b5a22b12650b3f1b.zip
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/service/am/applets/applet_web_browser.cpp6
-rw-r--r--src/core/hle/service/filesystem/filesystem.cpp30
-rw-r--r--src/core/hle/service/filesystem/filesystem.h15
-rw-r--r--src/core/hle/service/filesystem/fsp/fs_i_directory.cpp26
-rw-r--r--src/core/hle/service/filesystem/fsp/fs_i_directory.h7
-rw-r--r--src/core/hle/service/filesystem/fsp/fs_i_file.h1
-rw-r--r--src/core/hle/service/filesystem/fsp/fs_i_filesystem.cpp10
-rw-r--r--src/core/hle/service/filesystem/fsp/fsp_srv.cpp8
8 files changed, 50 insertions, 53 deletions
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 @@
#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);
}
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 @@
#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);
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 @@
#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
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 @@
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);
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 @@
#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);
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 @@
#pragma once
-#include "core/file_sys/vfs.h"
#include "core/hle/service/filesystem/filesystem.h"
#include "core/hle/service/service.h"
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 @@
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};
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 @@
#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"},
};