From owner-p4-projects@FreeBSD.ORG Fri Jul 18 13:20:27 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 180021065670; Fri, 18 Jul 2008 13:20:27 +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 CFDFD1065676 for ; Fri, 18 Jul 2008 13:20:26 +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 AEDEE8FC17 for ; Fri, 18 Jul 2008 13:20:26 +0000 (UTC) (envelope-from strauss@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m6IDKQ3l071919 for ; Fri, 18 Jul 2008 13:20:26 GMT (envelope-from strauss@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m6IDKQPc071917 for perforce@freebsd.org; Fri, 18 Jul 2008 13:20:26 GMT (envelope-from strauss@FreeBSD.org) Date: Fri, 18 Jul 2008 13:20:26 GMT Message-Id: <200807181320.m6IDKQPc071917@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 145424 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: Fri, 18 Jul 2008 13:20:27 -0000 http://perforce.freebsd.org/chv.cgi?CH=145424 Change 145424 by strauss@strauss_marvelman on 2008/07/18 13:19:28 added writing of offsets in central directory file headers Affected files ... .. //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_zip.c#13 edit Differences ... ==== //depot/projects/soc2008/strauss_libarchive/libarchive/archive_write_set_format_zip.c#13 (text+ko) ==== @@ -86,7 +86,7 @@ struct zip_file_header_link { struct zip_file_header_link *next; struct archive_entry *entry; - /* uint64_t offset; */ /* Whatfor? */ + off_t offset; }; struct zip { @@ -148,6 +148,23 @@ d = (struct zip_data_descriptor *) &zip->data_descriptor; path = archive_entry_pathname(entry); + /* Append archive entry to the central directory data. + * Storing in reverse order, for ease of coding. + * According to specification order should not matter, right? */ + l = (struct zip_file_header_link *) malloc(sizeof(*l)); + if (l == NULL) { + archive_set_error(&a->archive, ENOMEM, "Can't allocate zip header data"); + return (ARCHIVE_FATAL); + } + l->entry = entry; + l->next = zip->central_directory; + zip->central_directory = l; + + /* Store the offset of this header for later use in central directory. + * TODO: Offset actually are 8 bytes, for big archives this won't fit into + * the 4 bytes field. Either use ZIP64, or return error. */ + l->offset = a->archive.raw_position; + /* * Formatting local file header. * Some fields are not explicitely set after they were set to 0 @@ -176,19 +193,6 @@ ret = (a->compressor.write)(a, path, strlen(path)); if (ret != ARCHIVE_OK) return (ARCHIVE_FATAL); - - /* Append archive entry to the central directory data. - * Storing in reverse order, for ease of coding. - * According to specification order should not matter, right? */ - l = (struct zip_file_header_link *) malloc(sizeof(*l)); - if (l == NULL) { - archive_set_error(&a->archive, ENOMEM, "Can't allocate zip header data"); - return (ARCHIVE_FATAL); - } - l->entry = entry; - l->next = zip->central_directory; - zip->central_directory = l; - return (ARCHIVE_OK); } @@ -256,6 +260,7 @@ zip_encode(size, &h.compressed_size, sizeof(h.compressed_size)); zip_encode(size, &h.uncompressed_size, sizeof(h.uncompressed_size)); zip_encode(strlen(path), &h.filename_length, sizeof(h.filename_length)); + zip_encode(l->offset, &h.offset, sizeof(h.offset)); /* Writing file header. */ ret = (a->compressor.write)(a, &h, sizeof(h));