Portability: Not everyone is lucky enough to have ftruncate()

This commit is contained in:
Tim Kientzle 2008-09-12 04:08:11 +00:00
parent 220265229d
commit a2854491c4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=182955
2 changed files with 3 additions and 0 deletions

View File

@ -637,12 +637,14 @@ _archive_write_finish_entry(struct archive *_a)
/* Last write ended at exactly the filesize; we're done. */
/* Hopefully, this is the common case. */
} else {
#if HAVE_FTRUNCATE
if (ftruncate(a->fd, a->filesize) == -1 &&
a->filesize == 0) {
archive_set_error(&a->archive, errno,
"File size could not be restored");
return (ARCHIVE_FAILED);
}
#endif
/*
* Explicitly stat the file as some platforms might not
* implement the XSI option to extend files via ftruncate.

View File

@ -56,6 +56,7 @@
#define HAVE_FCNTL_H 1
#define HAVE_FSEEKO 1
#define HAVE_FSTAT 1
#define HAVE_FTRUNCATE 1
#define HAVE_FUTIMES 1
#define HAVE_GETEUID 1
#define HAVE_GETPID 1