From owner-p4-projects@FreeBSD.ORG Thu Aug 28 15:11:50 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 29DBC1065672; Thu, 28 Aug 2008 15:11:50 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E38951065670 for ; Thu, 28 Aug 2008 15:11:49 +0000 (UTC) (envelope-from strauss@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id D48D68FC1F for ; Thu, 28 Aug 2008 15:11:49 +0000 (UTC) (envelope-from strauss@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m7SFBn5c011409 for ; Thu, 28 Aug 2008 15:11:49 GMT (envelope-from strauss@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m7SFBnUG011397 for perforce@freebsd.org; Thu, 28 Aug 2008 15:11:49 GMT (envelope-from strauss@FreeBSD.org) Date: Thu, 28 Aug 2008 15:11:49 GMT Message-Id: <200808281511.m7SFBnUG011397@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to strauss@FreeBSD.org using -f From: Anselm Strauss To: Perforce Change Reviews Cc: Subject: PERFORCE change 148708 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Aug 2008 15:11:50 -0000 http://perforce.freebsd.org/chv.cgi?CH=148708 Change 148708 by strauss@strauss_marvelman on 2008/08/28 15:09:59 - Writing compressed and uncompressed sizes in local file header. - Uncommented remaining tests, except for permission restoring. Affected files ... .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_zip.c#40 edit .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_write_format_zip.c#5 edit .. //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_write_format_zip_no_compression.c#14 edit Differences ... ==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_zip.c#40 (text+ko) ==== @@ -268,7 +268,7 @@ * The fields this is true for and the reason why are: * * - compression: Not yet supported (TODO) - * - crc32, compressed_size, uncompressed_size: written in data descriptor + * - crc32: written in data descriptor * - extra_length: not used (TODO) */ memset(&h, 0, sizeof(h)); @@ -278,6 +278,10 @@ zip_encode(dos_time(archive_entry_mtime(entry)), &h.timedate, sizeof(h.timedate)); zip_encode(path_length(entry), &h.filename_length, sizeof(h.filename_length)); zip_encode(sizeof(e), &h.extra_length, sizeof(h.extra_length)); + /* Setting compressed and uncompressed sizes even when specification says + * to set to zero when using data descriptors. */ + zip_encode(size, &h.compressed_size, sizeof(h.compressed_size)); + zip_encode(size, &h.uncompressed_size, sizeof(h.uncompressed_size)); /* Formatting extra data. */ zip_encode(sizeof(e), &h.extra_length, sizeof(h.extra_length)); @@ -536,6 +540,7 @@ return (ARCHIVE_FATAL); written_bytes += strlen(path); + /* Folders are recognized by a traling slash. */ if ((type == AE_IFDIR) & (path[strlen(path) - 1] != '/')) { ret = (archive->compressor.write)(archive, "/", 1); if (ret != ARCHIVE_OK) ==== //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_write_format_zip.c#5 (text+ko) ==== @@ -28,6 +28,8 @@ * Development supported by Google Summer of Code 2008. */ +/* TODO: reader does not yet restore permissions. */ + #include "test.h" __FBSDID("$Id$ $Change$ $DateTime$ $Author$"); @@ -125,46 +127,44 @@ assertEqualInt(0, archive_entry_atime(ae)); assertEqualInt(0, archive_entry_ctime(ae)); assertEqualString("file", archive_entry_pathname(ae)); - /* TODO: reader does not yet restore permissions. */ - /* TODO: reader does not yet respect data descriptors. */ - /*assertEqualInt((S_IFREG | 0755), archive_entry_mode(ae)); + //assertEqualInt((S_IFREG | 0755), archive_entry_mode(ae)); assertEqualInt(8, archive_entry_size(ae)); assertEqualIntA(a, archive_entry_size(ae), archive_read_data(a, filedata, sizeof(filedata))); - assertEqualMem(filedata, "12345678", 8);*/ + assertEqualMem(filedata, "12345678", 8); /* * Read the second file back. */ - /*assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualInt(1, archive_entry_mtime(ae)); assertEqualInt(0, archive_entry_mtime_nsec(ae)); assertEqualInt(0, archive_entry_atime(ae)); assertEqualInt(0, archive_entry_ctime(ae)); assertEqualString("file2", archive_entry_pathname(ae)); - assert((S_IFREG | 0755) == archive_entry_mode(ae)); + //assert((S_IFREG | 0755) == archive_entry_mode(ae)); assertEqualInt(4, archive_entry_size(ae)); assertEqualIntA(a, archive_entry_size(ae), archive_read_data(a, filedata, sizeof(filedata))); - assertEqualMem(filedata, "1234", 4);*/ + assertEqualMem(filedata, "1234", 4); /* * Read the dir entry back. */ - /*assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); + assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae)); assertEqualInt(11, archive_entry_mtime(ae)); assertEqualInt(0, archive_entry_mtime_nsec(ae)); assertEqualInt(0, archive_entry_atime(ae)); assertEqualInt(0, archive_entry_ctime(ae)); - assertEqualString("dir", archive_entry_pathname(ae)); - assertEqualInt((S_IFDIR | 0755), archive_entry_mode(ae)); + assertEqualString("dir/", archive_entry_pathname(ae)); + //assertEqualInt((S_IFDIR | 0755), archive_entry_mode(ae)); assertEqualInt(0, archive_entry_size(ae)); - assertEqualIntA(a, 0, archive_read_data(a, filedata, 10));*/ + assertEqualIntA(a, 0, archive_read_data(a, filedata, 10)); /* Verify the end of the archive. */ - /*assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); + assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae)); assertEqualInt(ARCHIVE_OK, archive_read_close(a)); assertEqualInt(ARCHIVE_OK, archive_read_finish(a)); - free(buff);*/ + free(buff); } ==== //depot/projects/soc2008/strauss_libarchive/libarchive/test/test_write_format_zip_no_compression.c#14 (text+ko) ==== @@ -178,8 +178,8 @@ assertEqualInt(i2(q + 10), (tm->tm_hour * 2048) + (tm->tm_min * 32) + (tm->tm_sec / 2)); /* File time */ assertEqualInt(i2(q + 12), ((tm->tm_year - 80) * 512) + ((tm->tm_mon + 1) * 32) + tm->tm_mday); /* File date */ assertEqualInt(i4(q + 14), 0); /* CRC-32 */ - assertEqualInt(i4(q + 18), 0); /* Compressed size */ - assertEqualInt(i4(q + 22), 0); /* Uncompressed size */ + assertEqualInt(i4(q + 18), sizeof(file_data1) + sizeof(file_data2)); /* Compressed size */ + assertEqualInt(i4(q + 22), sizeof(file_data1) + sizeof(file_data2)); /* Uncompressed size */ assertEqualInt(i2(q + 26), strlen(file_name)); /* Pathname length */ assertEqualInt(i2(q + 28), 25); /* Extra field length */ assertEqualMem(q + 30, file_name, strlen(file_name)); /* Pathname */