Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Aug 2008 15:11:49 GMT
From:      Anselm Strauss <strauss@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 148708 for review
Message-ID:  <200808281511.m7SFBnUG011397@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808281511.m7SFBnUG011397>