diff -ur --exclude='*o' libarchive-3.1.2_clean/libarchive-3.1.2/libarchive/archive.h libarchive-3.1.2/libarchive/archive.h --- libarchive-3.1.2_clean/libarchive-3.1.2/libarchive/archive.h 2013-02-09 18:23:03.000000000 +0100 +++ libarchive-3.1.2/libarchive/archive.h 2013-04-05 09:47:26.000000000 +0200 @@ -739,6 +739,14 @@ /* Apply option string to both the format and the filter. */ __LA_DECL int archive_write_set_options(struct archive *_a, const char *opts); +/* EXASOL change begin */ +/* Set uncompressed size of entry + * Because of streaming, size is not known in advance + * Size must be updated after the file has been compressed + */ +__LA_DECL int archive_write_zip_set_uncompressed_entry_size(struct archive *_a, + __LA_INT64_T); +/* EXASOL change end */ /*- * ARCHIVE_WRITE_DISK API diff -ur --exclude='*o' libarchive-3.1.2_clean/libarchive-3.1.2/libarchive/archive_write_set_format_zip.c libarchive-3.1.2/libarchive/archive_write_set_format_zip.c --- libarchive-3.1.2_clean/libarchive-3.1.2/libarchive/archive_write_set_format_zip.c 2013-01-14 02:43:45.000000000 +0100 +++ libarchive-3.1.2/libarchive/archive_write_set_format_zip.c 2013-04-05 10:03:49.000000000 +0200 @@ -361,6 +361,21 @@ return (ARCHIVE_OK); } +/* EXASOL change begin */ +/* Update uncompressed entry size */ +int +archive_write_zip_set_uncompressed_entry_size(struct archive *_a, __LA_INT64_T s) +{ + struct archive_write *a = (struct archive_write *)_a; + struct zip *zip = a->format_data; + struct zip_file_header_link *l = zip->central_directory_end; + + archive_entry_set_size(l->entry, s); + + return (ARCHIVE_OK); +} +/* EXASOL change end */ + static int is_all_ascii(const char *p) { @@ -546,15 +561,24 @@ * specification says to set to zero when using data * descriptors. Otherwise the end of the data for an * entry is rather difficult to find. */ - archive_le32enc(&h[LOCAL_FILE_HEADER_COMPRESSED_SIZE], - (uint32_t)size); - archive_le32enc(&h[LOCAL_FILE_HEADER_UNCOMPRESSED_SIZE], - (uint32_t)size); + + /* EXASOL change begin */ + /* Do not set size in local file header + * Because of streaming, size is not known */ + /* archive_le32enc(&h[LOCAL_FILE_HEADER_COMPRESSED_SIZE], + * (uint32_t)size); + * archive_le32enc(&h[LOCAL_FILE_HEADER_UNCOMPRESSED_SIZE], + * (uint32_t)size); */ + /* EXASOL change end */ break; #ifdef HAVE_ZLIB_H case COMPRESSION_DEFLATE: - archive_le32enc(&h[LOCAL_FILE_HEADER_UNCOMPRESSED_SIZE], - (uint32_t)size); + /* EXASOL change begin */ + /* Do not set size in local file header + * Because of streaming, size is not known */ + /* archive_le32enc(&h[LOCAL_FILE_HEADER_UNCOMPRESSED_SIZE], + * (uint32_t)size); */ + /* EXASOL change end */ zip->stream.zalloc = Z_NULL; zip->stream.zfree = Z_NULL; @@ -722,6 +746,12 @@ archive_le32enc(&d[DATA_DESCRIPTOR_CRC32], l->crc32); archive_le32enc(&d[DATA_DESCRIPTOR_COMPRESSED_SIZE], (uint32_t)l->compressed_size); + /* EXASOL change begin */ + /* Write (updated) uncompressed entry size into data descriptor + * Because of streaming, size is not contained in local file header */ + archive_le32enc(&d[DATA_DESCRIPTOR_UNCOMPRESSED_SIZE], + (uint32_t)archive_entry_size(l->entry)); + /* EXASOL change end */ ret = __archive_write_output(a, d, SIZE_DATA_DESCRIPTOR); if (ret != ARCHIVE_OK) return (ARCHIVE_FATAL);