Portability: Not everyone is lucky enough to have ftruncate()
This commit is contained in:
parent
220265229d
commit
a2854491c4
@ -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.
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user