From ccdf5b420c98da86504569985859e9c0c043f4bf Mon Sep 17 00:00:00 2001 From: kientzle Date: Fri, 12 Sep 2008 04:08:11 +0000 Subject: Portability: Not everyone is lucky enough to have ftruncate() --- lib/libarchive/archive_write_disk.c | 2 ++ lib/libarchive/config_freebsd.h | 1 + 2 files changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/libarchive/archive_write_disk.c b/lib/libarchive/archive_write_disk.c index f0bec6e..8b364f2 100644 --- a/lib/libarchive/archive_write_disk.c +++ b/lib/libarchive/archive_write_disk.c @@ -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. diff --git a/lib/libarchive/config_freebsd.h b/lib/libarchive/config_freebsd.h index a8ea8b4..4c97bb2 100644 --- a/lib/libarchive/config_freebsd.h +++ b/lib/libarchive/config_freebsd.h @@ -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 -- cgit v1.1