From owner-p4-projects@FreeBSD.ORG Wed Jul 9 14:21:45 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id B3E311065674; Wed, 9 Jul 2008 14:21:45 +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 287EC106564A for ; Wed, 9 Jul 2008 14:21:45 +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 192338FC1D for ; Wed, 9 Jul 2008 14:21:45 +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 m69ELin4077195 for ; Wed, 9 Jul 2008 14:21:44 GMT (envelope-from strauss@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m69ELie4077193 for perforce@freebsd.org; Wed, 9 Jul 2008 14:21:44 GMT (envelope-from strauss@FreeBSD.org) Date: Wed, 9 Jul 2008 14:21:44 GMT Message-Id: <200807091421.m69ELie4077193@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 144943 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: Wed, 09 Jul 2008 14:21:46 -0000 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