Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Jul 2008 15:08:26 GMT
From:      Anselm Strauss <strauss@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 146324 for review
Message-ID:  <200807311508.m6VF8QUD097494@repoman.freebsd.org>

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

Change 146324 by strauss@strauss_marvelman on 2008/07/31 15:07:29

	Setting archive errors before returning failures (not sure about the error numbers)

Affected files ...

.. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_zip.c#22 edit

Differences ...

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

@@ -155,8 +155,10 @@
 archive_write_zip_header(struct archive_write *a, struct archive_entry *entry)
 {
 	/* TODO: Also handle non-regular file entries. */
-	if (archive_entry_filetype(entry) != AE_IFREG)
+	if (archive_entry_filetype(entry) != AE_IFREG) {
+		archive_set_error(&a->archive, EPERM, "Non-regular files are not yet supported.");
 		return ARCHIVE_FAILED;
+	};
 	
 	struct zip *zip;
 	struct zip_local_file_header h;
@@ -207,11 +209,17 @@
 	zip_encode(size, &d->uncompressed_size, sizeof(d->uncompressed_size));
 	
 	ret = (a->compressor.write)(a, &h, sizeof(h));
-	if (ret != ARCHIVE_OK) return (ARCHIVE_FATAL);
+	if (ret != ARCHIVE_OK) {
+		archive_set_error(&a->archive, EIO, "Can't write local file header");
+		return (ARCHIVE_FATAL);
+	}
 	zip->written_bytes += sizeof(h);
 	
 	ret = (a->compressor.write)(a, path, strlen(path));
-	if (ret != ARCHIVE_OK) return (ARCHIVE_FATAL);
+	if (ret != ARCHIVE_OK) {
+		archive_set_error(&a->archive, EIO, "Can't write path field");
+		return (ARCHIVE_FATAL);
+	}
 	zip->written_bytes += strlen(path);
 
 	return (ARCHIVE_OK);
@@ -228,6 +236,7 @@
 		zip->written_bytes += s;
 		return (s);
 	} else {
+		archive_set_error(&a->archive, EIO, "Error while writing ZIP data");
 		return (ret);
 	}
 		
@@ -244,11 +253,13 @@
 	struct zip_data_descriptor *d = &zip->data_descriptor;
 	
 	ret = (a->compressor.write)(a, d, sizeof(*d));
-	if (ret != ARCHIVE_OK)
+	if (ret != ARCHIVE_OK) {
+		archive_set_error(&a->archive, EIO, "Can't write data descriptor");
 		return (ARCHIVE_FATAL);
+	}
 	
 	zip->written_bytes += sizeof(*d);
-	return (ret);
+	return (ARCHIVE_OK);
 }
 
 static int
@@ -296,12 +307,18 @@
 		
 		/* Writing file header. */
 		ret = (a->compressor.write)(a, &h, sizeof(h));
-		if (ret != ARCHIVE_OK) return (ARCHIVE_FATAL);
+		if (ret != ARCHIVE_OK) {
+			archive_set_error(&a->archive, EIO, "Can't write file header");
+			return (ARCHIVE_FATAL);
+		}
 		zip->written_bytes += sizeof(h);
 		
 		/* Writing filename. */
 		ret = (a->compressor.write)(a, path, strlen(path));
-		if (ret != ARCHIVE_OK) return (ARCHIVE_FATAL);
+		if (ret != ARCHIVE_OK) {
+			archive_set_error(&a->archive, EIO, "Can't write path field");
+			return (ARCHIVE_FATAL);
+		}
 		zip->written_bytes += strlen(path);
 		
 		l = l->next;
@@ -319,7 +336,10 @@
 	
 	/* Writing end of central directory. */
 	ret = (a->compressor.write)(a, &end, sizeof(end));
-	if (ret != ARCHIVE_OK) return (ARCHIVE_FATAL);
+	if (ret != ARCHIVE_OK) {
+		archive_set_error(&a->archive, EIO, "Can't write end of central directory");
+		return (ARCHIVE_FATAL);
+	}
 	zip->written_bytes += sizeof(end);
 	
 	return (ARCHIVE_OK);



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