You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by or...@io7m.com on 2013/11/12 19:36:01 UTC

[compress] Random access of SevenZFile

Hello.

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).

Is there some way to get constant-time random access to files?

I could, presumably, generate a map of filenames to SevenZArchiveEntry instances upon archive
loading, but is there a better way?

M

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [compress] Random access of SevenZFile

Posted by or...@io7m.com.
On Wed, 13 Nov 2013 06:05:06 +0100
Stefan Bodewig <bo...@apache.org> wrote:

> On 2013-11-12, <or...@io7m.com> 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

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [compress] Random access of SevenZFile

Posted by Stefan Bodewig <bo...@apache.org>.
On 2013-11-12, <or...@io7m.com> 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

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org