fssystem: add RomFsFileSystem

This commit is contained in:
Michael Scire
2020-04-04 02:37:21 -07:00
parent a50d6a2696
commit 8d1ada2a1b
17 changed files with 2057 additions and 21 deletions

View File

@@ -202,7 +202,7 @@ namespace ams::fs {
virtual Result OpenFileImpl(std::unique_ptr<fsa::IFile> *out_file, const char *path, OpenMode mode) override final {
/* Only allow opening files with mode = read. */
R_UNLESS((mode & fs::OpenMode_All) == fs::OpenMode_Read, fs::ResultInvalidArgument());
R_UNLESS((mode & fs::OpenMode_All) == fs::OpenMode_Read, fs::ResultInvalidOpenMode());
/* If we support redirection, we'd like to prefer a file from the sd card. */
if (this->is_redirect) {
@@ -252,7 +252,7 @@ namespace ams::fs {
R_UNLESS(this->initialized, fs::ResultNotInitialized());
/* Only allow opening files with mode = read. */
R_UNLESS((mode & fs::OpenMode_All) == fs::OpenMode_Read, fs::ResultInvalidArgument());
R_UNLESS((mode & fs::OpenMode_All) == fs::OpenMode_Read, fs::ResultInvalidOpenMode());
/* First, check if there's an external code. */
{

View File

@@ -233,6 +233,13 @@ namespace ams::fs {
{
R_UNLESS(offset >= 0, fs::ResultOutOfRange());
R_UNLESS(this->GetSize() >= 0, fs::ResultOutOfRange());
auto operate_size = size;
if (offset + operate_size > this->GetSize() || offset + operate_size < offset) {
operate_size = this->GetSize() - offset;
}
return this->GetStorage()->OperateRange(dst, dst_size, op_id, this->start + offset, operate_size, src, src_size);
}
default:
return fs::ResultUnsupportedOperationInRomFsFileB();
@@ -481,7 +488,7 @@ namespace ams::fs {
AMS_ASSERT(out_file != nullptr);
AMS_ASSERT(path != nullptr);
R_UNLESS((mode & fs::OpenMode_All) == fs::OpenMode_Read, fs::ResultInvalidArgument());
R_UNLESS((mode & fs::OpenMode_All) == fs::OpenMode_Read, fs::ResultInvalidOpenMode());
RomFileTable::FileInfo file_info;
R_TRY(this->GetFileInfo(std::addressof(file_info), path));
@@ -515,7 +522,8 @@ namespace ams::fs {
}
Result RomFsFileSystem::GetFreeSpaceSizeImpl(s64 *out, const char *path) {
return fs::ResultUnsupportedOperationInRomFsFileSystemC();
*out = 0;
return ResultSuccess();
}
Result RomFsFileSystem::GetTotalSpaceSizeImpl(s64 *out, const char *path) {