mirror of
https://github.com/jakcron/nstool.git
synced 2024-12-22 10:45:28 +00:00
[fnd] Added read/write methods to IFile that didn't require an offset.
This commit is contained in:
parent
45954d837d
commit
949bc4ba27
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue