diff --git a/src/file.cpp b/src/file.cpp index c6ed419e..0d3e3011 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -396,6 +396,17 @@ void OutputFile::rewrite(const void *buf, int len) void OutputFile::seek(off_t off, int whence) { 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); }