summaryrefslogtreecommitdiffstats
path: root/src/core/file_sys/disk_archive.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/file_sys/disk_archive.cpp')
-rw-r--r--src/core/file_sys/disk_archive.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/core/file_sys/disk_archive.cpp b/src/core/file_sys/disk_archive.cpp
index 0c55a4863..2dca895fd 100644
--- a/src/core/file_sys/disk_archive.cpp
+++ b/src/core/file_sys/disk_archive.cpp
@@ -124,17 +124,23 @@ bool DiskFile::Open() {
return file->IsOpen();
}
-size_t DiskFile::Read(const u64 offset, const size_t length, u8* buffer) const {
+ResultVal<size_t> DiskFile::Read(const u64 offset, const size_t length, u8* buffer) const {
+ if (!mode.read_flag && !mode.write_flag)
+ return ResultCode(ErrorDescription::FS_InvalidOpenFlags, ErrorModule::FS, ErrorSummary::Canceled, ErrorLevel::Status);
+
file->Seek(offset, SEEK_SET);
- return file->ReadBytes(buffer, length);
+ return MakeResult<size_t>(file->ReadBytes(buffer, length));
}
-size_t DiskFile::Write(const u64 offset, const size_t length, const bool flush, const u8* buffer) const {
+ResultVal<size_t> DiskFile::Write(const u64 offset, const size_t length, const bool flush, const u8* buffer) const {
+ if (!mode.write_flag)
+ return ResultCode(ErrorDescription::FS_InvalidOpenFlags, ErrorModule::FS, ErrorSummary::Canceled, ErrorLevel::Status);
+
file->Seek(offset, SEEK_SET);
size_t written = file->WriteBytes(buffer, length);
if (flush)
file->Flush();
- return written;
+ return MakeResult<size_t>(written);
}
u64 DiskFile::GetSize() const {