diff --git a/libc/src/stdio.cpp b/libc/src/stdio.cpp index 4f09faf1..4e3440ff 100644 --- a/libc/src/stdio.cpp +++ b/libc/src/stdio.cpp @@ -350,6 +350,8 @@ extern "C" int fseek(FILE* stream, long offset, int whence) { + fflush(stream); + long result = lseek(stream->_fd, offset, whence); if (result < 0) return -1; @@ -361,11 +363,15 @@ extern "C" long ftell(FILE* stream) { + fflush(stream); + return lseek(stream->_fd, 0, SEEK_CUR); } void rewind(FILE* stream) { + fflush(stream); + lseek(stream->_fd, 0, SEEK_SET); clearerr(stream); @@ -383,6 +389,8 @@ extern "C" int fsetpos(FILE* stream, const fpos_t* pos) { + fflush(stream); + return fseek(stream, *pos, SEEK_SET); }