diff --git a/lib/libfnd/include/fnd/IFile.h b/lib/libfnd/include/fnd/IFile.h index 6a7cc56..3c12bba 100644 --- a/lib/libfnd/include/fnd/IFile.h +++ b/lib/libfnd/include/fnd/IFile.h @@ -8,7 +8,9 @@ namespace fnd public: virtual size_t size() = 0; virtual void seek(size_t offset) = 0; + virtual void read(byte_t* out, size_t len) = 0; virtual void read(byte_t* out, size_t offset, size_t len) = 0; + virtual void write(const byte_t* out, size_t len) = 0; virtual void write(const byte_t* out, size_t offset, size_t len) = 0; }; } diff --git a/lib/libfnd/include/fnd/SimpleFile.h b/lib/libfnd/include/fnd/SimpleFile.h index bb25f7d..8499dd9 100644 --- a/lib/libfnd/include/fnd/SimpleFile.h +++ b/lib/libfnd/include/fnd/SimpleFile.h @@ -24,7 +24,9 @@ namespace fnd size_t size(); void seek(size_t offset); size_t pos(); + void read(byte_t* out, size_t len); void read(byte_t* out, size_t offset, size_t len); + void write(const byte_t* out, size_t len); void write(const byte_t* out, size_t offset, size_t len); private: diff --git a/lib/libfnd/source/SimpleFile.cpp b/lib/libfnd/source/SimpleFile.cpp index bb907d3..b12156a 100644 --- a/lib/libfnd/source/SimpleFile.cpp +++ b/lib/libfnd/source/SimpleFile.cpp @@ -60,16 +60,26 @@ size_t SimpleFile::pos() return ftell(mFp); } +void SimpleFile::read(byte_t* out, size_t len) +{ + fread(out, len, 1, mFp); +} + void SimpleFile::read(byte_t* out, size_t offset, size_t len) { seek(offset); - fread(out, len, 1, mFp); + read(out, len); +} + +void SimpleFile::write(const byte_t* out, size_t len) +{ + fwrite(out, len, 1, mFp); } void SimpleFile::write(const byte_t* out, size_t offset, size_t len) { seek(offset); - fwrite(out, len, 1, mFp); + write(out, len); } const char* SimpleFile::getOpenModeStr(OpenMode mode)