diff options
author | Dan Fandrich <dan@coneharvesters.com> | 2005-03-07 18:59:04 +0000 |
---|---|---|
committer | Dan Fandrich <dan@coneharvesters.com> | 2005-03-07 18:59:04 +0000 |
commit | dc5979562921779dbceb377ea9768bacf04563da (patch) | |
tree | 549b6378f2f918facec08350bded19f40ff8a47a | |
parent | cb9bb31f7da82d8ec4a1b6c8d3d1e2ea82d1f996 (diff) |
fseek() with SEEK_SET is broken on large file capable 32-bit systems, so
revert to the SEEK_END method of repositioning the stream after a ftruncate()
and only use SEEK_SET if ftruncate() isn't available.
-rw-r--r-- | src/main.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/main.c b/src/main.c index 43e9c4939..2d80e726f 100644 --- a/src/main.c +++ b/src/main.c @@ -3773,10 +3773,16 @@ operate(struct Configurable *config, int argc, char *argv[]) /* truncate file at the position where we started appending */ #ifdef HAVE_FTRUNCATE ftruncate( fileno(outs.stream), outs.init); -#endif /* now seek to the end of the file, the position where we - just truncated the file */ - fseek(outs.stream, outs.init, SEEK_SET); + just truncated the file in a large file-safe way */ + fseek(outs.stream, 0, SEEK_END); +#else + /* ftruncate is not available, so just reposition the file + to the location we would have truncated it. This won't + work properly with large files on 32-bit systems, but + most of those will have ftruncate. */ + fseek(outs.stream, (long)outs.init, SEEK_SET); +#endif outs.bytes = 0; /* clear for next round */ } continue; |