summaryrefslogtreecommitdiffstats
path: root/winsup/mingw/mingwex/stdio/fseeko64.c
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/mingw/mingwex/stdio/fseeko64.c')
-rwxr-xr-xwinsup/mingw/mingwex/stdio/fseeko64.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/winsup/mingw/mingwex/stdio/fseeko64.c b/winsup/mingw/mingwex/stdio/fseeko64.c
index 94e17e929..d8dcc0c44 100755
--- a/winsup/mingw/mingwex/stdio/fseeko64.c
+++ b/winsup/mingw/mingwex/stdio/fseeko64.c
@@ -14,7 +14,11 @@ fseeko64 (FILE* stream, off64_t offset, int whence)
pos += (fpos_t) offset;
}
else if (whence == SEEK_END)
- pos = (fpos_t) (_filelengthi64 (_fileno (stream)) + offset);
+ {
+ /* If writing, we need to flush before getting file length. */
+ fflush (stream);
+ pos = (fpos_t) (_filelengthi64 (_fileno (stream)) + offset);
+ }
else if (whence == SEEK_SET)
pos = (fpos_t) offset;
else
@@ -24,4 +28,3 @@ fseeko64 (FILE* stream, off64_t offset, int whence)
}
return fsetpos (stream, &pos);
}
-