mirror of
https://github.com/jakcron/nstool.git
synced 2024-12-23 03:05:27 +00:00
[nstool] Fixed a bug in OffsetAdjustedIFile that failed to track file position.
This commit is contained in:
parent
7c024c290b
commit
e1ccf81e54
|
@ -36,13 +36,14 @@ size_t OffsetAdjustedIFile::size()
|
||||||
void OffsetAdjustedIFile::seek(size_t offset)
|
void OffsetAdjustedIFile::seek(size_t offset)
|
||||||
{
|
{
|
||||||
mCurrentOffset = MIN(offset, mSize);
|
mCurrentOffset = MIN(offset, mSize);
|
||||||
mFile->seek(offset + mBaseOffset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffsetAdjustedIFile::read(byte_t* out, size_t len)
|
void OffsetAdjustedIFile::read(byte_t* out, size_t len)
|
||||||
{
|
{
|
||||||
seek(mCurrentOffset);
|
// assert proper position in file
|
||||||
|
mFile->seek(mCurrentOffset + mBaseOffset);
|
||||||
mFile->read(out, len);
|
mFile->read(out, len);
|
||||||
|
mCurrentOffset += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffsetAdjustedIFile::read(byte_t* out, size_t offset, size_t len)
|
void OffsetAdjustedIFile::read(byte_t* out, size_t offset, size_t len)
|
||||||
|
@ -53,8 +54,10 @@ void OffsetAdjustedIFile::read(byte_t* out, size_t offset, size_t len)
|
||||||
|
|
||||||
void OffsetAdjustedIFile::write(const byte_t* out, size_t len)
|
void OffsetAdjustedIFile::write(const byte_t* out, size_t len)
|
||||||
{
|
{
|
||||||
seek(mCurrentOffset);
|
// assert proper position in file
|
||||||
|
mFile->seek(mCurrentOffset + mBaseOffset);
|
||||||
mFile->write(out, len);
|
mFile->write(out, len);
|
||||||
|
mCurrentOffset += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffsetAdjustedIFile::write(const byte_t* out, size_t offset, size_t len)
|
void OffsetAdjustedIFile::write(const byte_t* out, size_t offset, size_t len)
|
||||||
|
|
Loading…
Reference in a new issue