From: Michihiro NAKAJIMA Date: Wed, 4 Jan 2012 06:43:12 +0000 (-0500) Subject: Remove POSIX specific code about taking care of ftruncate failure. X-Git-Tag: v3.0.4~2^2~220 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68bcd6fb191e2f8ef1cb75af7f666f72b933bb5d;p=thirdparty%2Flibarchive.git Remove POSIX specific code about taking care of ftruncate failure. SVN-Revision: 4085 --- diff --git a/libarchive/archive_write_disk_windows.c b/libarchive/archive_write_disk_windows.c index 07dffb737..28ad3f10b 100644 --- a/libarchive/archive_write_disk_windows.c +++ b/libarchive/archive_write_disk_windows.c @@ -1050,41 +1050,11 @@ _archive_write_disk_finish_entry(struct archive *_a) /* Last write ended at exactly the filesize; we're done. */ /* Hopefully, this is the common case. */ } else { - if (la_ftruncate(a->fh, a->filesize) == -1 && - a->filesize == 0) { + if (la_ftruncate(a->fh, a->filesize) == -1) { archive_set_error(&a->archive, errno, "File size could not be restored"); return (ARCHIVE_FAILED); } - /* - * Not all platforms implement the XSI option to - * extend files via ftruncate. Stat() the file again - * to see what happened. - */ - a->pst = NULL; - if ((ret = lazy_stat(a)) != ARCHIVE_OK) - return (ret); - /* We can use lseek()/write() to extend the file if - * ftruncate didn't work or isn't available. */ - if (bhfi_size(&(a->st)) < a->filesize) { - OVERLAPPED ol; - const char nul = '\0'; - - memset(&ol, 0, sizeof(ol)); - ol.Offset = (DWORD)((a->filesize -1) & 0xFFFFFFFF); - ol.OffsetHigh = (DWORD)((a->filesize -1) >> 32); - if (!WriteFile(a->fh, &nul, 1, NULL, &ol)) { - DWORD lasterr = GetLastError(); - if (lasterr == ERROR_ACCESS_DENIED) - errno = EBADF; - else - la_dosmaperr(lasterr); - archive_set_error(&a->archive, errno, - "Write to restore size failed"); - return (ARCHIVE_FATAL); - } - a->pst = NULL; - } } /* Restore metadata. */