fix OutputFile::seek() for SEEK_SET and SEEK_END
This commit is contained in:
@@ -396,6 +396,17 @@ void OutputFile::rewrite(const void *buf, int len)
|
|||||||
void OutputFile::seek(off_t off, int whence)
|
void OutputFile::seek(off_t off, int whence)
|
||||||
{
|
{
|
||||||
assert(!opt->to_stdout);
|
assert(!opt->to_stdout);
|
||||||
|
switch (whence) {
|
||||||
|
case SEEK_SET: {
|
||||||
|
if (bytes_written < off) {
|
||||||
|
bytes_written = off;
|
||||||
|
}
|
||||||
|
_length = bytes_written; // cheap, lazy update; needed?
|
||||||
|
} break;
|
||||||
|
case SEEK_END: {
|
||||||
|
_length = bytes_written; // necessary
|
||||||
|
} break;
|
||||||
|
}
|
||||||
super::seek(off,whence);
|
super::seek(off,whence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user