Service/FS: Mark FileBackend's Write as non-const

This commit is contained in:
shinyquagsire23 2017-10-25 17:55:11 -06:00
parent ca2b6c6c8e
commit 714206e4ce
9 changed files with 9 additions and 12 deletions

View file

@ -35,8 +35,7 @@ public:
return false; return false;
} }
ResultVal<size_t> Write(u64 offset, size_t length, bool flush, ResultVal<size_t> Write(u64 offset, size_t length, bool flush, const u8* buffer) override {
const u8* buffer) const override {
if (offset > size) { if (offset > size) {
return ERR_WRITE_BEYOND_END; return ERR_WRITE_BEYOND_END;
} else if (offset == size) { } else if (offset == size) {

View file

@ -206,7 +206,7 @@ ResultVal<size_t> NCCHFile::Read(const u64 offset, const size_t length, u8* buff
} }
ResultVal<size_t> NCCHFile::Write(const u64 offset, const size_t length, const bool flush, ResultVal<size_t> NCCHFile::Write(const u64 offset, const size_t length, const bool flush,
const u8* buffer) const { const u8* buffer) {
LOG_ERROR(Service_FS, "Attempted to write to NCCH file"); LOG_ERROR(Service_FS, "Attempted to write to NCCH file");
// TODO(shinyquagsire23): Find error code // TODO(shinyquagsire23): Find error code
return MakeResult<size_t>(0); return MakeResult<size_t>(0);

View file

@ -54,7 +54,7 @@ public:
NCCHFile(std::vector<u8> buffer) : file_buffer(buffer) {} NCCHFile(std::vector<u8> buffer) : file_buffer(buffer) {}
ResultVal<size_t> Read(u64 offset, size_t length, u8* buffer) const override; ResultVal<size_t> Read(u64 offset, size_t length, u8* buffer) const override;
ResultVal<size_t> Write(u64 offset, size_t length, bool flush, const u8* buffer) const override; ResultVal<size_t> Write(u64 offset, size_t length, bool flush, const u8* buffer) override;
u64 GetSize() const override; u64 GetSize() const override;
bool SetSize(u64 size) const override; bool SetSize(u64 size) const override;
bool Close() const override { bool Close() const override {

View file

@ -51,8 +51,7 @@ public:
return MakeResult<size_t>(data->size()); return MakeResult<size_t>(data->size());
} }
ResultVal<size_t> Write(u64 offset, size_t length, bool flush, ResultVal<size_t> Write(u64 offset, size_t length, bool flush, const u8* buffer) override {
const u8* buffer) const override {
LOG_ERROR(Service_FS, "The file is read-only!"); LOG_ERROR(Service_FS, "The file is read-only!");
return ERROR_UNSUPPORTED_OPEN_FLAGS; return ERROR_UNSUPPORTED_OPEN_FLAGS;
} }

View file

@ -25,7 +25,7 @@ ResultVal<size_t> DiskFile::Read(const u64 offset, const size_t length, u8* buff
} }
ResultVal<size_t> DiskFile::Write(const u64 offset, const size_t length, const bool flush, ResultVal<size_t> DiskFile::Write(const u64 offset, const size_t length, const bool flush,
const u8* buffer) const { const u8* buffer) {
if (!mode.write_flag) if (!mode.write_flag)
return ERROR_INVALID_OPEN_FLAGS; return ERROR_INVALID_OPEN_FLAGS;

View file

@ -28,7 +28,7 @@ public:
} }
ResultVal<size_t> Read(u64 offset, size_t length, u8* buffer) const override; ResultVal<size_t> Read(u64 offset, size_t length, u8* buffer) const override;
ResultVal<size_t> Write(u64 offset, size_t length, bool flush, const u8* buffer) const override; ResultVal<size_t> Write(u64 offset, size_t length, bool flush, const u8* buffer) override;
u64 GetSize() const override; u64 GetSize() const override;
bool SetSize(u64 size) const override; bool SetSize(u64 size) const override;
bool Close() const override; bool Close() const override;

View file

@ -35,8 +35,7 @@ public:
* @param buffer Buffer to read data from * @param buffer Buffer to read data from
* @return Number of bytes written, or error code * @return Number of bytes written, or error code
*/ */
virtual ResultVal<size_t> Write(u64 offset, size_t length, bool flush, virtual ResultVal<size_t> Write(u64 offset, size_t length, bool flush, const u8* buffer) = 0;
const u8* buffer) const = 0;
/** /**
* Get the size of the file in bytes * Get the size of the file in bytes

View file

@ -94,7 +94,7 @@ ResultVal<size_t> IVFCFile::Read(const u64 offset, const size_t length, u8* buff
} }
ResultVal<size_t> IVFCFile::Write(const u64 offset, const size_t length, const bool flush, ResultVal<size_t> IVFCFile::Write(const u64 offset, const size_t length, const bool flush,
const u8* buffer) const { const u8* buffer) {
LOG_ERROR(Service_FS, "Attempted to write to IVFC file"); LOG_ERROR(Service_FS, "Attempted to write to IVFC file");
// TODO(Subv): Find error code // TODO(Subv): Find error code
return MakeResult<size_t>(0); return MakeResult<size_t>(0);

View file

@ -56,7 +56,7 @@ public:
: romfs_file(file), data_offset(offset), data_size(size) {} : romfs_file(file), data_offset(offset), data_size(size) {}
ResultVal<size_t> Read(u64 offset, size_t length, u8* buffer) const override; ResultVal<size_t> Read(u64 offset, size_t length, u8* buffer) const override;
ResultVal<size_t> Write(u64 offset, size_t length, bool flush, const u8* buffer) const override; ResultVal<size_t> Write(u64 offset, size_t length, bool flush, const u8* buffer) override;
u64 GetSize() const override; u64 GetSize() const override;
bool SetSize(u64 size) const override; bool SetSize(u64 size) const override;
bool Close() const override { bool Close() const override {