Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Jul 2008 14:21:44 GMT
From:      Anselm Strauss <strauss@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 144943 for review
Message-ID:  <200807091421.m69ELie4077193@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=144943

Change 144943 by strauss@strauss_marvelman on 2008/07/09 14:21:09

	Data descriptor stuff

Affected files ...

.. //depot/projects/soc2008/strauss_libarchive/TODO#7 edit
.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_zip.c#6 edit

Differences ...

==== //depot/projects/soc2008/strauss_libarchive/TODO#7 (text+ko) ====

@@ -1,10 +1,11 @@
 To Be Done
 ==========
 
+- Exception handling in ZIP writer
+- Update ZIP writer in docs
+- Integrate Libarchive 2.5.5
 - About the keywords: of course they always change when integrating ...
 - Not all P4 keywords do expand (tested on OS X and FreeBSD)
-- Integrate libarchive 2.5.5
-- Update ZIP writer in docs
 
 
 Already Done

==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_zip.c#6 (text+ko) ====

@@ -118,10 +118,12 @@
 		return ARCHIVE_FAILED;
 	
 	struct zip *zip;
+	struct zip_local_file_header h;
+	struct zip_data_descriptor *d;
 	int ret;
-	struct zip_local_file_header h;
-
-	zip = (struct zip *)a->format_data;
+	
+	zip = (struct zip *) a->format_data;
+	d = (struct zip_data_descriptor *) &zip->data_descriptor;
 	ret = 0;
 
 	memset(&h, 0, sizeof(h));
@@ -152,6 +154,9 @@
 	
 	/* TODO: Append entry to central directory. */
 	
+	encode(archive_entry_size(entry), &d->compressed_size, sizeof(d->compressed_size));
+	encode(archive_entry_size(entry), &d->uncompressed_size, sizeof(d->uncompressed_size));
+	
 	ret = (a->compressor.write)(a, &h, sizeof(h));
 	if (ret != ARCHIVE_OK)
 		return (ARCHIVE_FATAL);
@@ -162,15 +167,25 @@
 static ssize_t
 archive_write_zip_data(struct archive_write *a, const void *buff, size_t s)
 {
-	return (a->compressor.write)(a, buff, s);
-	/* TODO: Compute data descriptor fields. */
+	int ret;
+	ret = (a->compressor.write)(a, buff, s);
+	if (ret != ARCHIVE_OK)
+		return (ARCHIVE_FATAL);
+	return (ret);
+	
+	/* TODO: Compute data descriptor CRC. */
 }
 
 static int
 archive_write_zip_finish_entry(struct archive_write *a)
 {
-	/* TODO: Write data descriptor. */
-	return 0;
+	int ret;
+	struct zip *zip = (struct zip *) a->format_data;
+	struct zip_data_descriptor *d = (struct zip_data_descriptor *) &zip->data_descriptor;
+	ret = (a->compressor.write)(a, d, sizeof(d));
+	if (ret != ARCHIVE_OK)
+		return (ARCHIVE_FATAL);
+	return (ret);
 }
 
 static int



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