libc: Flush buffers before dealing with file positions
This commit is contained in:
parent
420270ebd4
commit
19b4aa9f81
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user