Return-Path: X-Original-To: apmail-commons-user-archive@www.apache.org Delivered-To: apmail-commons-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1FA8D1084E for ; Wed, 13 Nov 2013 13:28:33 +0000 (UTC) Received: (qmail 10254 invoked by uid 500); 13 Nov 2013 13:28:28 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 10183 invoked by uid 500); 13 Nov 2013 13:28:27 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 10175 invoked by uid 99); 13 Nov 2013 13:28:26 -0000 Received: from minotaur.apache.org (HELO minotaur.apache.org) (140.211.11.9) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Nov 2013 13:28:26 +0000 Received: from localhost (HELO mail-we0-f169.google.com) (127.0.0.1) (smtp-auth username damjan, mechanism plain) by minotaur.apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Nov 2013 13:28:25 +0000 Received: by mail-we0-f169.google.com with SMTP id q58so420433wes.0 for ; Wed, 13 Nov 2013 05:28:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:from:date:message-id:subject:to:content-type; bh=8pMIE0R1diDxwY+v+hUhAT3D41kROHoAicu+hq5LHm4=; b=SLpJmgGRQA74MDZHcPHb/2yqvzsVpd81njhOgXeICMR0Xe+ZNqFqZWLId1YrFVrCcb IM4RLMA7BvQqY+QqEbZOTzfKv/V+1w+HpH3hkgC1F5B9z5vVlDoIcBn4rtcQYs3/jjxP 167pnCs3myFPXPeGbIIbX1IV+I/E+IWcGQMmxxQSKCtXOOT2HFic60Au5RmPmNd2Aj4X OtLQtIqHqkaRyW+f0wQ5V7DI/katSVXI8IfBTLpMrx9uet3hPMTRnIms4vUdze7tN/l7 1xRQN1+lxGmGH0BujUx4t4Ad4gJRJ20XSsDZnCrNRNi8ZB38iezuXZIjxu3QlbPqS/dU C0ug== X-Received: by 10.180.90.65 with SMTP id bu1mr4200254wib.15.1384349304397; Wed, 13 Nov 2013 05:28:24 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.124.6 with HTTP; Wed, 13 Nov 2013 05:28:04 -0800 (PST) From: Damjan Jovanovic Date: Wed, 13 Nov 2013 15:28:04 +0200 Message-ID: Subject: Re: [compress] Random access of SevenZFile To: Commons Users List Content-Type: text/plain; charset=ISO-8859-1 On Wed, Nov 13, 2013 at 3:18 PM, wrote: > On Wed, 13 Nov 2013 06:05:06 +0100 > Stefan Bodewig wrote: > >> On 2013-11-12, wrote: >> >> > The 7z file format is (supposedly) a random access format, much like >> > zip archives. However, The SevenZFile class seems to only expose a >> > sequential interface (where I'm expected to seek over entries one at a >> > time, presumably whilst unpacking files). >> >> Much like zip 7z has file metadata at the end of the archive, so yes, >> SevenZFile could build up a Map when opening the archive and provide >> random access. Actually it does collect the information of all entries >> (in Archive.files), only an API to use it for random access is missing. >> >> Things aren't all that bad, though. Repeatedly calling getNextEntry >> will create streams for each entry but not consume them - so the files >> are not unpacked while you iterate over the entries. >> >> Stefan > > Hello! > > I spent a bit of time yesterday implementing this; I build a HashMap of > names to SevenZArchiveEntry instances by iterating over all entries upon > archive loading. > > However, I'm having further problems actually obtaining streams to specific > entries. The only interface exposed by SevenZFile is a set of mostly > undocumented read() functions that don't state where the data comes from. > The documentation for the no-argument read() function states > "Read a byte of data". > > I'm assuming that the functions will actually read from the byte offset > in the file described by the most recent entry returned by getNextEntry(). > Unfortunately, given that there's apparently no way to seek, this seems to > imply that I can't do anything with a SevenZFile beyond sequentially > decompressing all entries in order. This makes it essentially useless for > my needs (writing an interactive archive management program). > > Am I missing something obvious here? > > M It is not possible to seek to an arbitrary file's contents in a 7z archive anyway, since 7z archives can use solid compression for some or all files, which means you potentially have to sequentially decompress some or all of the preceding files' contents to get to the contents of the one you want. Damjan --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org