mirror of
https://github.com/jakcron/nstool
synced 2024-11-22 21:49:30 +00:00
[fnd] Added read/write methods to IFile that didn't require an offset.
This commit is contained in:
parent
45954d837d
commit
949bc4ba27
3 changed files with 16 additions and 2 deletions
|
@ -8,7 +8,9 @@ namespace fnd
|
||||||
public:
|
public:
|
||||||
virtual size_t size() = 0;
|
virtual size_t size() = 0;
|
||||||
virtual void seek(size_t offset) = 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 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;
|
virtual void write(const byte_t* out, size_t offset, size_t len) = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,9 @@ namespace fnd
|
||||||
size_t size();
|
size_t size();
|
||||||
void seek(size_t offset);
|
void seek(size_t offset);
|
||||||
size_t pos();
|
size_t pos();
|
||||||
|
void read(byte_t* out, size_t len);
|
||||||
void read(byte_t* out, size_t offset, 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);
|
void write(const byte_t* out, size_t offset, size_t len);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -60,16 +60,26 @@ size_t SimpleFile::pos()
|
||||||
return ftell(mFp);
|
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)
|
void SimpleFile::read(byte_t* out, size_t offset, size_t len)
|
||||||
{
|
{
|
||||||
seek(offset);
|
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)
|
void SimpleFile::write(const byte_t* out, size_t offset, size_t len)
|
||||||
{
|
{
|
||||||
seek(offset);
|
seek(offset);
|
||||||
fwrite(out, len, 1, mFp);
|
write(out, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* SimpleFile::getOpenModeStr(OpenMode mode)
|
const char* SimpleFile::getOpenModeStr(OpenMode mode)
|
||||||
|
|
Loading…
Reference in a new issue