[nstool] Fixed a bug in OffsetAdjustedIFile that failed to track file position.

This commit is contained in:
jakcron 2018-05-22 19:38:05 +08:00
parent 7c024c290b
commit e1ccf81e54

View file

@ -36,13 +36,14 @@ size_t OffsetAdjustedIFile::size()
void OffsetAdjustedIFile::seek(size_t offset)
{
mCurrentOffset = MIN(offset, mSize);
mFile->seek(offset + mBaseOffset);
}
void OffsetAdjustedIFile::read(byte_t* out, size_t len)
{
seek(mCurrentOffset);
// assert proper position in file
mFile->seek(mCurrentOffset + mBaseOffset);
mFile->read(out, len);
mCurrentOffset += 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)
{
seek(mCurrentOffset);
// assert proper position in file
mFile->seek(mCurrentOffset + mBaseOffset);
mFile->write(out, len);
mCurrentOffset += len;
}
void OffsetAdjustedIFile::write(const byte_t* out, size_t offset, size_t len)