filesystem: Add const qualification to various accessors
This commit is contained in:
parent
d4d38dd44d
commit
a49169e819
|
@ -35,7 +35,7 @@ void RomFSFactory::SetPackedUpdate(VirtualFile update_raw) {
|
||||||
this->update_raw = std::move(update_raw);
|
this->update_raw = std::move(update_raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess() {
|
ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess() const {
|
||||||
if (!updatable)
|
if (!updatable)
|
||||||
return MakeResult<VirtualFile>(file);
|
return MakeResult<VirtualFile>(file);
|
||||||
|
|
||||||
|
@ -44,7 +44,8 @@ ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess() {
|
||||||
patch_manager.PatchRomFS(file, ivfc_offset, ContentRecordType::Program, update_raw));
|
patch_manager.PatchRomFS(file, ivfc_offset, ContentRecordType::Program, update_raw));
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage, ContentRecordType type) {
|
ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage,
|
||||||
|
ContentRecordType type) const {
|
||||||
std::shared_ptr<NCA> res;
|
std::shared_ptr<NCA> res;
|
||||||
|
|
||||||
switch (storage) {
|
switch (storage) {
|
||||||
|
|
|
@ -33,8 +33,8 @@ public:
|
||||||
~RomFSFactory();
|
~RomFSFactory();
|
||||||
|
|
||||||
void SetPackedUpdate(VirtualFile update_raw);
|
void SetPackedUpdate(VirtualFile update_raw);
|
||||||
ResultVal<VirtualFile> OpenCurrentProcess();
|
ResultVal<VirtualFile> OpenCurrentProcess() const;
|
||||||
ResultVal<VirtualFile> Open(u64 title_id, StorageId storage, ContentRecordType type);
|
ResultVal<VirtualFile> Open(u64 title_id, StorageId storage, ContentRecordType type) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VirtualFile file;
|
VirtualFile file;
|
||||||
|
|
|
@ -71,7 +71,7 @@ SaveDataFactory::SaveDataFactory(VirtualDir save_directory) : dir(std::move(save
|
||||||
SaveDataFactory::~SaveDataFactory() = default;
|
SaveDataFactory::~SaveDataFactory() = default;
|
||||||
|
|
||||||
ResultVal<VirtualDir> SaveDataFactory::Create(SaveDataSpaceId space,
|
ResultVal<VirtualDir> SaveDataFactory::Create(SaveDataSpaceId space,
|
||||||
const SaveDataDescriptor& meta) {
|
const SaveDataDescriptor& meta) const {
|
||||||
PrintSaveDataDescriptorWarnings(meta);
|
PrintSaveDataDescriptorWarnings(meta);
|
||||||
|
|
||||||
const auto save_directory =
|
const auto save_directory =
|
||||||
|
@ -88,7 +88,8 @@ ResultVal<VirtualDir> SaveDataFactory::Create(SaveDataSpaceId space,
|
||||||
return MakeResult<VirtualDir>(std::move(out));
|
return MakeResult<VirtualDir>(std::move(out));
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space, const SaveDataDescriptor& meta) {
|
ResultVal<VirtualDir> SaveDataFactory::Open(SaveDataSpaceId space,
|
||||||
|
const SaveDataDescriptor& meta) const {
|
||||||
|
|
||||||
const auto save_directory =
|
const auto save_directory =
|
||||||
GetFullPath(space, meta.type, meta.title_id, meta.user_id, meta.save_id);
|
GetFullPath(space, meta.type, meta.title_id, meta.user_id, meta.save_id);
|
||||||
|
@ -165,7 +166,7 @@ SaveDataSize SaveDataFactory::ReadSaveDataSize(SaveDataType type, u64 title_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
void SaveDataFactory::WriteSaveDataSize(SaveDataType type, u64 title_id, u128 user_id,
|
void SaveDataFactory::WriteSaveDataSize(SaveDataType type, u64 title_id, u128 user_id,
|
||||||
SaveDataSize new_value) {
|
SaveDataSize new_value) const {
|
||||||
const auto path = GetFullPath(SaveDataSpaceId::NandUser, type, title_id, user_id, 0);
|
const auto path = GetFullPath(SaveDataSpaceId::NandUser, type, title_id, user_id, 0);
|
||||||
const auto dir = GetOrCreateDirectoryRelative(this->dir, path);
|
const auto dir = GetOrCreateDirectoryRelative(this->dir, path);
|
||||||
|
|
||||||
|
|
|
@ -64,8 +64,8 @@ public:
|
||||||
explicit SaveDataFactory(VirtualDir dir);
|
explicit SaveDataFactory(VirtualDir dir);
|
||||||
~SaveDataFactory();
|
~SaveDataFactory();
|
||||||
|
|
||||||
ResultVal<VirtualDir> Create(SaveDataSpaceId space, const SaveDataDescriptor& meta);
|
ResultVal<VirtualDir> Create(SaveDataSpaceId space, const SaveDataDescriptor& meta) const;
|
||||||
ResultVal<VirtualDir> Open(SaveDataSpaceId space, const SaveDataDescriptor& meta);
|
ResultVal<VirtualDir> Open(SaveDataSpaceId space, const SaveDataDescriptor& meta) const;
|
||||||
|
|
||||||
VirtualDir GetSaveDataSpaceDirectory(SaveDataSpaceId space) const;
|
VirtualDir GetSaveDataSpaceDirectory(SaveDataSpaceId space) const;
|
||||||
|
|
||||||
|
@ -74,7 +74,8 @@ public:
|
||||||
u128 user_id, u64 save_id);
|
u128 user_id, u64 save_id);
|
||||||
|
|
||||||
SaveDataSize ReadSaveDataSize(SaveDataType type, u64 title_id, u128 user_id) const;
|
SaveDataSize ReadSaveDataSize(SaveDataType type, u64 title_id, u128 user_id) const;
|
||||||
void WriteSaveDataSize(SaveDataType type, u64 title_id, u128 user_id, SaveDataSize new_value);
|
void WriteSaveDataSize(SaveDataType type, u64 title_id, u128 user_id,
|
||||||
|
SaveDataSize new_value) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VirtualDir dir;
|
VirtualDir dir;
|
||||||
|
|
|
@ -21,7 +21,7 @@ SDMCFactory::SDMCFactory(VirtualDir dir_)
|
||||||
|
|
||||||
SDMCFactory::~SDMCFactory() = default;
|
SDMCFactory::~SDMCFactory() = default;
|
||||||
|
|
||||||
ResultVal<VirtualDir> SDMCFactory::Open() {
|
ResultVal<VirtualDir> SDMCFactory::Open() const {
|
||||||
return MakeResult<VirtualDir>(dir);
|
return MakeResult<VirtualDir>(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ public:
|
||||||
explicit SDMCFactory(VirtualDir dir);
|
explicit SDMCFactory(VirtualDir dir);
|
||||||
~SDMCFactory();
|
~SDMCFactory();
|
||||||
|
|
||||||
ResultVal<VirtualDir> Open();
|
ResultVal<VirtualDir> Open() const;
|
||||||
|
|
||||||
VirtualDir GetSDMCContentDirectory() const;
|
VirtualDir GetSDMCContentDirectory() const;
|
||||||
|
|
||||||
|
|
|
@ -241,6 +241,10 @@ ResultVal<FileSys::EntryType> VfsDirectoryServiceWrapper::GetEntryType(
|
||||||
return FileSys::ERROR_PATH_NOT_FOUND;
|
return FileSys::ERROR_PATH_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileSystemController::FileSystemController() = default;
|
||||||
|
|
||||||
|
FileSystemController::~FileSystemController() = default;
|
||||||
|
|
||||||
ResultCode FileSystemController::RegisterRomFS(std::unique_ptr<FileSys::RomFSFactory>&& factory) {
|
ResultCode FileSystemController::RegisterRomFS(std::unique_ptr<FileSys::RomFSFactory>&& factory) {
|
||||||
romfs_factory = std::move(factory);
|
romfs_factory = std::move(factory);
|
||||||
LOG_DEBUG(Service_FS, "Registered RomFS");
|
LOG_DEBUG(Service_FS, "Registered RomFS");
|
||||||
|
@ -278,7 +282,7 @@ void FileSystemController::SetPackedUpdate(FileSys::VirtualFile update_raw) {
|
||||||
romfs_factory->SetPackedUpdate(std::move(update_raw));
|
romfs_factory->SetPackedUpdate(std::move(update_raw));
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultVal<FileSys::VirtualFile> FileSystemController::OpenRomFSCurrentProcess() {
|
ResultVal<FileSys::VirtualFile> FileSystemController::OpenRomFSCurrentProcess() const {
|
||||||
LOG_TRACE(Service_FS, "Opening RomFS for current process");
|
LOG_TRACE(Service_FS, "Opening RomFS for current process");
|
||||||
|
|
||||||
if (romfs_factory == nullptr) {
|
if (romfs_factory == nullptr) {
|
||||||
|
@ -289,9 +293,8 @@ ResultVal<FileSys::VirtualFile> FileSystemController::OpenRomFSCurrentProcess()
|
||||||
return romfs_factory->OpenCurrentProcess();
|
return romfs_factory->OpenCurrentProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultVal<FileSys::VirtualFile> FileSystemController::OpenRomFS(u64 title_id,
|
ResultVal<FileSys::VirtualFile> FileSystemController::OpenRomFS(
|
||||||
FileSys::StorageId storage_id,
|
u64 title_id, FileSys::StorageId storage_id, FileSys::ContentRecordType type) const {
|
||||||
FileSys::ContentRecordType type) {
|
|
||||||
LOG_TRACE(Service_FS, "Opening RomFS for title_id={:016X}, storage_id={:02X}, type={:02X}",
|
LOG_TRACE(Service_FS, "Opening RomFS for title_id={:016X}, storage_id={:02X}, type={:02X}",
|
||||||
title_id, static_cast<u8>(storage_id), static_cast<u8>(type));
|
title_id, static_cast<u8>(storage_id), static_cast<u8>(type));
|
||||||
|
|
||||||
|
@ -304,7 +307,7 @@ ResultVal<FileSys::VirtualFile> FileSystemController::OpenRomFS(u64 title_id,
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultVal<FileSys::VirtualDir> FileSystemController::CreateSaveData(
|
ResultVal<FileSys::VirtualDir> FileSystemController::CreateSaveData(
|
||||||
FileSys::SaveDataSpaceId space, const FileSys::SaveDataDescriptor& save_struct) {
|
FileSys::SaveDataSpaceId space, const FileSys::SaveDataDescriptor& save_struct) const {
|
||||||
LOG_TRACE(Service_FS, "Creating Save Data for space_id={:01X}, save_struct={}",
|
LOG_TRACE(Service_FS, "Creating Save Data for space_id={:01X}, save_struct={}",
|
||||||
static_cast<u8>(space), save_struct.DebugInfo());
|
static_cast<u8>(space), save_struct.DebugInfo());
|
||||||
|
|
||||||
|
@ -316,7 +319,7 @@ ResultVal<FileSys::VirtualDir> FileSystemController::CreateSaveData(
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultVal<FileSys::VirtualDir> FileSystemController::OpenSaveData(
|
ResultVal<FileSys::VirtualDir> FileSystemController::OpenSaveData(
|
||||||
FileSys::SaveDataSpaceId space, const FileSys::SaveDataDescriptor& descriptor) {
|
FileSys::SaveDataSpaceId space, const FileSys::SaveDataDescriptor& descriptor) const {
|
||||||
LOG_TRACE(Service_FS, "Opening Save Data for space_id={:01X}, save_struct={}",
|
LOG_TRACE(Service_FS, "Opening Save Data for space_id={:01X}, save_struct={}",
|
||||||
static_cast<u8>(space), descriptor.DebugInfo());
|
static_cast<u8>(space), descriptor.DebugInfo());
|
||||||
|
|
||||||
|
@ -328,7 +331,7 @@ ResultVal<FileSys::VirtualDir> FileSystemController::OpenSaveData(
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultVal<FileSys::VirtualDir> FileSystemController::OpenSaveDataSpace(
|
ResultVal<FileSys::VirtualDir> FileSystemController::OpenSaveDataSpace(
|
||||||
FileSys::SaveDataSpaceId space) {
|
FileSys::SaveDataSpaceId space) const {
|
||||||
LOG_TRACE(Service_FS, "Opening Save Data Space for space_id={:01X}", static_cast<u8>(space));
|
LOG_TRACE(Service_FS, "Opening Save Data Space for space_id={:01X}", static_cast<u8>(space));
|
||||||
|
|
||||||
if (save_data_factory == nullptr) {
|
if (save_data_factory == nullptr) {
|
||||||
|
@ -338,7 +341,7 @@ ResultVal<FileSys::VirtualDir> FileSystemController::OpenSaveDataSpace(
|
||||||
return MakeResult(save_data_factory->GetSaveDataSpaceDirectory(space));
|
return MakeResult(save_data_factory->GetSaveDataSpaceDirectory(space));
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultVal<FileSys::VirtualDir> FileSystemController::OpenSDMC() {
|
ResultVal<FileSys::VirtualDir> FileSystemController::OpenSDMC() const {
|
||||||
LOG_TRACE(Service_FS, "Opening SDMC");
|
LOG_TRACE(Service_FS, "Opening SDMC");
|
||||||
|
|
||||||
if (sdmc_factory == nullptr) {
|
if (sdmc_factory == nullptr) {
|
||||||
|
@ -348,7 +351,8 @@ ResultVal<FileSys::VirtualDir> FileSystemController::OpenSDMC() {
|
||||||
return sdmc_factory->Open();
|
return sdmc_factory->Open();
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultVal<FileSys::VirtualDir> FileSystemController::OpenBISPartition(FileSys::BisPartitionId id) {
|
ResultVal<FileSys::VirtualDir> FileSystemController::OpenBISPartition(
|
||||||
|
FileSys::BisPartitionId id) const {
|
||||||
LOG_TRACE(Service_FS, "Opening BIS Partition with id={:08X}", static_cast<u32>(id));
|
LOG_TRACE(Service_FS, "Opening BIS Partition with id={:08X}", static_cast<u32>(id));
|
||||||
|
|
||||||
if (bis_factory == nullptr) {
|
if (bis_factory == nullptr) {
|
||||||
|
@ -364,7 +368,7 @@ ResultVal<FileSys::VirtualDir> FileSystemController::OpenBISPartition(FileSys::B
|
||||||
}
|
}
|
||||||
|
|
||||||
ResultVal<FileSys::VirtualFile> FileSystemController::OpenBISPartitionStorage(
|
ResultVal<FileSys::VirtualFile> FileSystemController::OpenBISPartitionStorage(
|
||||||
FileSys::BisPartitionId id) {
|
FileSys::BisPartitionId id) const {
|
||||||
LOG_TRACE(Service_FS, "Opening BIS Partition Storage with id={:08X}", static_cast<u32>(id));
|
LOG_TRACE(Service_FS, "Opening BIS Partition Storage with id={:08X}", static_cast<u32>(id));
|
||||||
|
|
||||||
if (bis_factory == nullptr) {
|
if (bis_factory == nullptr) {
|
||||||
|
@ -432,7 +436,7 @@ u64 FileSystemController::GetTotalSpaceSize(FileSys::StorageId id) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::SaveDataSize FileSystemController::ReadSaveDataSize(FileSys::SaveDataType type,
|
FileSys::SaveDataSize FileSystemController::ReadSaveDataSize(FileSys::SaveDataType type,
|
||||||
u64 title_id, u128 user_id) {
|
u64 title_id, u128 user_id) const {
|
||||||
if (save_data_factory == nullptr) {
|
if (save_data_factory == nullptr) {
|
||||||
return {0, 0};
|
return {0, 0};
|
||||||
}
|
}
|
||||||
|
@ -465,7 +469,7 @@ FileSys::SaveDataSize FileSystemController::ReadSaveDataSize(FileSys::SaveDataTy
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileSystemController::WriteSaveDataSize(FileSys::SaveDataType type, u64 title_id, u128 user_id,
|
void FileSystemController::WriteSaveDataSize(FileSys::SaveDataType type, u64 title_id, u128 user_id,
|
||||||
FileSys::SaveDataSize new_value) {
|
FileSys::SaveDataSize new_value) const {
|
||||||
if (save_data_factory != nullptr)
|
if (save_data_factory != nullptr)
|
||||||
save_data_factory->WriteSaveDataSize(type, title_id, user_id, new_value);
|
save_data_factory->WriteSaveDataSize(type, title_id, user_id, new_value);
|
||||||
}
|
}
|
||||||
|
@ -477,19 +481,19 @@ void FileSystemController::SetGameCard(FileSys::VirtualFile file) {
|
||||||
gamecard_placeholder = std::make_unique<FileSys::PlaceholderCache>(dir);
|
gamecard_placeholder = std::make_unique<FileSys::PlaceholderCache>(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::XCI* FileSystemController::GetGameCard() {
|
FileSys::XCI* FileSystemController::GetGameCard() const {
|
||||||
return gamecard.get();
|
return gamecard.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::RegisteredCache* FileSystemController::GetGameCardContents() {
|
FileSys::RegisteredCache* FileSystemController::GetGameCardContents() const {
|
||||||
return gamecard_registered.get();
|
return gamecard_registered.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::PlaceholderCache* FileSystemController::GetGameCardPlaceholder() {
|
FileSys::PlaceholderCache* FileSystemController::GetGameCardPlaceholder() const {
|
||||||
return gamecard_placeholder.get();
|
return gamecard_placeholder.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::RegisteredCache* FileSystemController::GetSystemNANDContents() {
|
FileSys::RegisteredCache* FileSystemController::GetSystemNANDContents() const {
|
||||||
LOG_TRACE(Service_FS, "Opening System NAND Contents");
|
LOG_TRACE(Service_FS, "Opening System NAND Contents");
|
||||||
|
|
||||||
if (bis_factory == nullptr)
|
if (bis_factory == nullptr)
|
||||||
|
@ -498,7 +502,7 @@ FileSys::RegisteredCache* FileSystemController::GetSystemNANDContents() {
|
||||||
return bis_factory->GetSystemNANDContents();
|
return bis_factory->GetSystemNANDContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::RegisteredCache* FileSystemController::GetUserNANDContents() {
|
FileSys::RegisteredCache* FileSystemController::GetUserNANDContents() const {
|
||||||
LOG_TRACE(Service_FS, "Opening User NAND Contents");
|
LOG_TRACE(Service_FS, "Opening User NAND Contents");
|
||||||
|
|
||||||
if (bis_factory == nullptr)
|
if (bis_factory == nullptr)
|
||||||
|
@ -507,7 +511,7 @@ FileSys::RegisteredCache* FileSystemController::GetUserNANDContents() {
|
||||||
return bis_factory->GetUserNANDContents();
|
return bis_factory->GetUserNANDContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::RegisteredCache* FileSystemController::GetSDMCContents() {
|
FileSys::RegisteredCache* FileSystemController::GetSDMCContents() const {
|
||||||
LOG_TRACE(Service_FS, "Opening SDMC Contents");
|
LOG_TRACE(Service_FS, "Opening SDMC Contents");
|
||||||
|
|
||||||
if (sdmc_factory == nullptr)
|
if (sdmc_factory == nullptr)
|
||||||
|
@ -516,7 +520,7 @@ FileSys::RegisteredCache* FileSystemController::GetSDMCContents() {
|
||||||
return sdmc_factory->GetSDMCContents();
|
return sdmc_factory->GetSDMCContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::PlaceholderCache* FileSystemController::GetSystemNANDPlaceholder() {
|
FileSys::PlaceholderCache* FileSystemController::GetSystemNANDPlaceholder() const {
|
||||||
LOG_TRACE(Service_FS, "Opening System NAND Placeholder");
|
LOG_TRACE(Service_FS, "Opening System NAND Placeholder");
|
||||||
|
|
||||||
if (bis_factory == nullptr)
|
if (bis_factory == nullptr)
|
||||||
|
@ -525,7 +529,7 @@ FileSys::PlaceholderCache* FileSystemController::GetSystemNANDPlaceholder() {
|
||||||
return bis_factory->GetSystemNANDPlaceholder();
|
return bis_factory->GetSystemNANDPlaceholder();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::PlaceholderCache* FileSystemController::GetUserNANDPlaceholder() {
|
FileSys::PlaceholderCache* FileSystemController::GetUserNANDPlaceholder() const {
|
||||||
LOG_TRACE(Service_FS, "Opening User NAND Placeholder");
|
LOG_TRACE(Service_FS, "Opening User NAND Placeholder");
|
||||||
|
|
||||||
if (bis_factory == nullptr)
|
if (bis_factory == nullptr)
|
||||||
|
@ -534,7 +538,7 @@ FileSys::PlaceholderCache* FileSystemController::GetUserNANDPlaceholder() {
|
||||||
return bis_factory->GetUserNANDPlaceholder();
|
return bis_factory->GetUserNANDPlaceholder();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::PlaceholderCache* FileSystemController::GetSDMCPlaceholder() {
|
FileSys::PlaceholderCache* FileSystemController::GetSDMCPlaceholder() const {
|
||||||
LOG_TRACE(Service_FS, "Opening SDMC Placeholder");
|
LOG_TRACE(Service_FS, "Opening SDMC Placeholder");
|
||||||
|
|
||||||
if (sdmc_factory == nullptr)
|
if (sdmc_factory == nullptr)
|
||||||
|
@ -544,7 +548,7 @@ FileSys::PlaceholderCache* FileSystemController::GetSDMCPlaceholder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::RegisteredCache* FileSystemController::GetRegisteredCacheForStorage(
|
FileSys::RegisteredCache* FileSystemController::GetRegisteredCacheForStorage(
|
||||||
FileSys::StorageId id) {
|
FileSys::StorageId id) const {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case FileSys::StorageId::None:
|
case FileSys::StorageId::None:
|
||||||
case FileSys::StorageId::Host:
|
case FileSys::StorageId::Host:
|
||||||
|
@ -564,7 +568,7 @@ FileSys::RegisteredCache* FileSystemController::GetRegisteredCacheForStorage(
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::PlaceholderCache* FileSystemController::GetPlaceholderCacheForStorage(
|
FileSys::PlaceholderCache* FileSystemController::GetPlaceholderCacheForStorage(
|
||||||
FileSys::StorageId id) {
|
FileSys::StorageId id) const {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case FileSys::StorageId::None:
|
case FileSys::StorageId::None:
|
||||||
case FileSys::StorageId::Host:
|
case FileSys::StorageId::Host:
|
||||||
|
@ -583,7 +587,7 @@ FileSys::PlaceholderCache* FileSystemController::GetPlaceholderCacheForStorage(
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::VirtualDir FileSystemController::GetSystemNANDContentDirectory() {
|
FileSys::VirtualDir FileSystemController::GetSystemNANDContentDirectory() const {
|
||||||
LOG_TRACE(Service_FS, "Opening system NAND content directory");
|
LOG_TRACE(Service_FS, "Opening system NAND content directory");
|
||||||
|
|
||||||
if (bis_factory == nullptr)
|
if (bis_factory == nullptr)
|
||||||
|
@ -592,7 +596,7 @@ FileSys::VirtualDir FileSystemController::GetSystemNANDContentDirectory() {
|
||||||
return bis_factory->GetSystemNANDContentDirectory();
|
return bis_factory->GetSystemNANDContentDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::VirtualDir FileSystemController::GetUserNANDContentDirectory() {
|
FileSys::VirtualDir FileSystemController::GetUserNANDContentDirectory() const {
|
||||||
LOG_TRACE(Service_FS, "Opening user NAND content directory");
|
LOG_TRACE(Service_FS, "Opening user NAND content directory");
|
||||||
|
|
||||||
if (bis_factory == nullptr)
|
if (bis_factory == nullptr)
|
||||||
|
@ -601,7 +605,7 @@ FileSys::VirtualDir FileSystemController::GetUserNANDContentDirectory() {
|
||||||
return bis_factory->GetUserNANDContentDirectory();
|
return bis_factory->GetUserNANDContentDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::VirtualDir FileSystemController::GetSDMCContentDirectory() {
|
FileSys::VirtualDir FileSystemController::GetSDMCContentDirectory() const {
|
||||||
LOG_TRACE(Service_FS, "Opening SDMC content directory");
|
LOG_TRACE(Service_FS, "Opening SDMC content directory");
|
||||||
|
|
||||||
if (sdmc_factory == nullptr)
|
if (sdmc_factory == nullptr)
|
||||||
|
@ -610,7 +614,7 @@ FileSys::VirtualDir FileSystemController::GetSDMCContentDirectory() {
|
||||||
return sdmc_factory->GetSDMCContentDirectory();
|
return sdmc_factory->GetSDMCContentDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::VirtualDir FileSystemController::GetNANDImageDirectory() {
|
FileSys::VirtualDir FileSystemController::GetNANDImageDirectory() const {
|
||||||
LOG_TRACE(Service_FS, "Opening NAND image directory");
|
LOG_TRACE(Service_FS, "Opening NAND image directory");
|
||||||
|
|
||||||
if (bis_factory == nullptr)
|
if (bis_factory == nullptr)
|
||||||
|
@ -619,7 +623,7 @@ FileSys::VirtualDir FileSystemController::GetNANDImageDirectory() {
|
||||||
return bis_factory->GetImageDirectory();
|
return bis_factory->GetImageDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::VirtualDir FileSystemController::GetSDMCImageDirectory() {
|
FileSys::VirtualDir FileSystemController::GetSDMCImageDirectory() const {
|
||||||
LOG_TRACE(Service_FS, "Opening SDMC image directory");
|
LOG_TRACE(Service_FS, "Opening SDMC image directory");
|
||||||
|
|
||||||
if (sdmc_factory == nullptr)
|
if (sdmc_factory == nullptr)
|
||||||
|
@ -628,7 +632,7 @@ FileSys::VirtualDir FileSystemController::GetSDMCImageDirectory() {
|
||||||
return sdmc_factory->GetImageDirectory();
|
return sdmc_factory->GetImageDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::VirtualDir FileSystemController::GetContentDirectory(ContentStorageId id) {
|
FileSys::VirtualDir FileSystemController::GetContentDirectory(ContentStorageId id) const {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case ContentStorageId::System:
|
case ContentStorageId::System:
|
||||||
return GetSystemNANDContentDirectory();
|
return GetSystemNANDContentDirectory();
|
||||||
|
@ -641,7 +645,7 @@ FileSys::VirtualDir FileSystemController::GetContentDirectory(ContentStorageId i
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::VirtualDir FileSystemController::GetImageDirectory(ImageDirectoryId id) {
|
FileSys::VirtualDir FileSystemController::GetImageDirectory(ImageDirectoryId id) const {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case ImageDirectoryId::NAND:
|
case ImageDirectoryId::NAND:
|
||||||
return GetNANDImageDirectory();
|
return GetNANDImageDirectory();
|
||||||
|
@ -652,7 +656,7 @@ FileSys::VirtualDir FileSystemController::GetImageDirectory(ImageDirectoryId id)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::VirtualDir FileSystemController::GetModificationLoadRoot(u64 title_id) {
|
FileSys::VirtualDir FileSystemController::GetModificationLoadRoot(u64 title_id) const {
|
||||||
LOG_TRACE(Service_FS, "Opening mod load root for tid={:016X}", title_id);
|
LOG_TRACE(Service_FS, "Opening mod load root for tid={:016X}", title_id);
|
||||||
|
|
||||||
if (bis_factory == nullptr)
|
if (bis_factory == nullptr)
|
||||||
|
@ -661,7 +665,7 @@ FileSys::VirtualDir FileSystemController::GetModificationLoadRoot(u64 title_id)
|
||||||
return bis_factory->GetModificationLoadRoot(title_id);
|
return bis_factory->GetModificationLoadRoot(title_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSys::VirtualDir FileSystemController::GetModificationDumpRoot(u64 title_id) {
|
FileSys::VirtualDir FileSystemController::GetModificationDumpRoot(u64 title_id) const {
|
||||||
LOG_TRACE(Service_FS, "Opening mod dump root for tid={:016X}", title_id);
|
LOG_TRACE(Service_FS, "Opening mod dump root for tid={:016X}", title_id);
|
||||||
|
|
||||||
if (bis_factory == nullptr)
|
if (bis_factory == nullptr)
|
||||||
|
|
|
@ -52,59 +52,63 @@ enum class ImageDirectoryId : u32 {
|
||||||
|
|
||||||
class FileSystemController {
|
class FileSystemController {
|
||||||
public:
|
public:
|
||||||
|
FileSystemController();
|
||||||
|
~FileSystemController();
|
||||||
|
|
||||||
ResultCode RegisterRomFS(std::unique_ptr<FileSys::RomFSFactory>&& factory);
|
ResultCode RegisterRomFS(std::unique_ptr<FileSys::RomFSFactory>&& factory);
|
||||||
ResultCode RegisterSaveData(std::unique_ptr<FileSys::SaveDataFactory>&& factory);
|
ResultCode RegisterSaveData(std::unique_ptr<FileSys::SaveDataFactory>&& factory);
|
||||||
ResultCode RegisterSDMC(std::unique_ptr<FileSys::SDMCFactory>&& factory);
|
ResultCode RegisterSDMC(std::unique_ptr<FileSys::SDMCFactory>&& factory);
|
||||||
ResultCode RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory);
|
ResultCode RegisterBIS(std::unique_ptr<FileSys::BISFactory>&& factory);
|
||||||
|
|
||||||
void SetPackedUpdate(FileSys::VirtualFile update_raw);
|
void SetPackedUpdate(FileSys::VirtualFile update_raw);
|
||||||
ResultVal<FileSys::VirtualFile> OpenRomFSCurrentProcess();
|
ResultVal<FileSys::VirtualFile> OpenRomFSCurrentProcess() const;
|
||||||
ResultVal<FileSys::VirtualFile> OpenRomFS(u64 title_id, FileSys::StorageId storage_id,
|
ResultVal<FileSys::VirtualFile> OpenRomFS(u64 title_id, FileSys::StorageId storage_id,
|
||||||
FileSys::ContentRecordType type);
|
FileSys::ContentRecordType type) const;
|
||||||
ResultVal<FileSys::VirtualDir> CreateSaveData(FileSys::SaveDataSpaceId space,
|
ResultVal<FileSys::VirtualDir> CreateSaveData(
|
||||||
const FileSys::SaveDataDescriptor& save_struct);
|
FileSys::SaveDataSpaceId space, const FileSys::SaveDataDescriptor& save_struct) const;
|
||||||
ResultVal<FileSys::VirtualDir> OpenSaveData(FileSys::SaveDataSpaceId space,
|
ResultVal<FileSys::VirtualDir> OpenSaveData(
|
||||||
const FileSys::SaveDataDescriptor& save_struct);
|
FileSys::SaveDataSpaceId space, const FileSys::SaveDataDescriptor& save_struct) const;
|
||||||
ResultVal<FileSys::VirtualDir> OpenSaveDataSpace(FileSys::SaveDataSpaceId space);
|
ResultVal<FileSys::VirtualDir> OpenSaveDataSpace(FileSys::SaveDataSpaceId space) const;
|
||||||
ResultVal<FileSys::VirtualDir> OpenSDMC();
|
ResultVal<FileSys::VirtualDir> OpenSDMC() const;
|
||||||
ResultVal<FileSys::VirtualDir> OpenBISPartition(FileSys::BisPartitionId id);
|
ResultVal<FileSys::VirtualDir> OpenBISPartition(FileSys::BisPartitionId id) const;
|
||||||
ResultVal<FileSys::VirtualFile> OpenBISPartitionStorage(FileSys::BisPartitionId id);
|
ResultVal<FileSys::VirtualFile> OpenBISPartitionStorage(FileSys::BisPartitionId id) const;
|
||||||
|
|
||||||
u64 GetFreeSpaceSize(FileSys::StorageId id) const;
|
u64 GetFreeSpaceSize(FileSys::StorageId id) const;
|
||||||
u64 GetTotalSpaceSize(FileSys::StorageId id) const;
|
u64 GetTotalSpaceSize(FileSys::StorageId id) const;
|
||||||
|
|
||||||
FileSys::SaveDataSize ReadSaveDataSize(FileSys::SaveDataType type, u64 title_id, u128 user_id);
|
FileSys::SaveDataSize ReadSaveDataSize(FileSys::SaveDataType type, u64 title_id,
|
||||||
|
u128 user_id) const;
|
||||||
void WriteSaveDataSize(FileSys::SaveDataType type, u64 title_id, u128 user_id,
|
void WriteSaveDataSize(FileSys::SaveDataType type, u64 title_id, u128 user_id,
|
||||||
FileSys::SaveDataSize new_value);
|
FileSys::SaveDataSize new_value) const;
|
||||||
|
|
||||||
void SetGameCard(FileSys::VirtualFile file);
|
void SetGameCard(FileSys::VirtualFile file);
|
||||||
FileSys::XCI* GetGameCard();
|
FileSys::XCI* GetGameCard() const;
|
||||||
|
|
||||||
FileSys::RegisteredCache* GetSystemNANDContents();
|
FileSys::RegisteredCache* GetSystemNANDContents() const;
|
||||||
FileSys::RegisteredCache* GetUserNANDContents();
|
FileSys::RegisteredCache* GetUserNANDContents() const;
|
||||||
FileSys::RegisteredCache* GetSDMCContents();
|
FileSys::RegisteredCache* GetSDMCContents() const;
|
||||||
FileSys::RegisteredCache* GetGameCardContents();
|
FileSys::RegisteredCache* GetGameCardContents() const;
|
||||||
|
|
||||||
FileSys::PlaceholderCache* GetSystemNANDPlaceholder();
|
FileSys::PlaceholderCache* GetSystemNANDPlaceholder() const;
|
||||||
FileSys::PlaceholderCache* GetUserNANDPlaceholder();
|
FileSys::PlaceholderCache* GetUserNANDPlaceholder() const;
|
||||||
FileSys::PlaceholderCache* GetSDMCPlaceholder();
|
FileSys::PlaceholderCache* GetSDMCPlaceholder() const;
|
||||||
FileSys::PlaceholderCache* GetGameCardPlaceholder();
|
FileSys::PlaceholderCache* GetGameCardPlaceholder() const;
|
||||||
|
|
||||||
FileSys::RegisteredCache* GetRegisteredCacheForStorage(FileSys::StorageId id);
|
FileSys::RegisteredCache* GetRegisteredCacheForStorage(FileSys::StorageId id) const;
|
||||||
FileSys::PlaceholderCache* GetPlaceholderCacheForStorage(FileSys::StorageId id);
|
FileSys::PlaceholderCache* GetPlaceholderCacheForStorage(FileSys::StorageId id) const;
|
||||||
|
|
||||||
FileSys::VirtualDir GetSystemNANDContentDirectory();
|
FileSys::VirtualDir GetSystemNANDContentDirectory() const;
|
||||||
FileSys::VirtualDir GetUserNANDContentDirectory();
|
FileSys::VirtualDir GetUserNANDContentDirectory() const;
|
||||||
FileSys::VirtualDir GetSDMCContentDirectory();
|
FileSys::VirtualDir GetSDMCContentDirectory() const;
|
||||||
|
|
||||||
FileSys::VirtualDir GetNANDImageDirectory();
|
FileSys::VirtualDir GetNANDImageDirectory() const;
|
||||||
FileSys::VirtualDir GetSDMCImageDirectory();
|
FileSys::VirtualDir GetSDMCImageDirectory() const;
|
||||||
|
|
||||||
FileSys::VirtualDir GetContentDirectory(ContentStorageId id);
|
FileSys::VirtualDir GetContentDirectory(ContentStorageId id) const;
|
||||||
FileSys::VirtualDir GetImageDirectory(ImageDirectoryId id);
|
FileSys::VirtualDir GetImageDirectory(ImageDirectoryId id) const;
|
||||||
|
|
||||||
FileSys::VirtualDir GetModificationLoadRoot(u64 title_id);
|
FileSys::VirtualDir GetModificationLoadRoot(u64 title_id) const;
|
||||||
FileSys::VirtualDir GetModificationDumpRoot(u64 title_id);
|
FileSys::VirtualDir GetModificationDumpRoot(u64 title_id) const;
|
||||||
|
|
||||||
// Creates the SaveData, SDMC, and BIS Factories. Should be called once and before any function
|
// Creates the SaveData, SDMC, and BIS Factories. Should be called once and before any function
|
||||||
// above is called.
|
// above is called.
|
||||||
|
|
|
@ -32,8 +32,8 @@
|
||||||
namespace Service::FileSystem {
|
namespace Service::FileSystem {
|
||||||
|
|
||||||
struct SizeGetter {
|
struct SizeGetter {
|
||||||
std::function<u64()> free;
|
std::function<u64()> get_free_size;
|
||||||
std::function<u64()> total;
|
std::function<u64()> get_total_size;
|
||||||
|
|
||||||
static SizeGetter FromStorageId(const FileSystemController& fsc, FileSys::StorageId id) {
|
static SizeGetter FromStorageId(const FileSystemController& fsc, FileSys::StorageId id) {
|
||||||
return {
|
return {
|
||||||
|
@ -485,7 +485,7 @@ public:
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 4};
|
IPC::ResponseBuilder rb{ctx, 4};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.Push(size.free());
|
rb.Push(size.get_free_size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetTotalSpaceSize(Kernel::HLERequestContext& ctx) {
|
void GetTotalSpaceSize(Kernel::HLERequestContext& ctx) {
|
||||||
|
@ -493,7 +493,7 @@ public:
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 4};
|
IPC::ResponseBuilder rb{ctx, 4};
|
||||||
rb.Push(RESULT_SUCCESS);
|
rb.Push(RESULT_SUCCESS);
|
||||||
rb.Push(size.total());
|
rb.Push(size.get_total_size());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue