Skip to content

Random entry access with the archive stream closed. #1348

Description

@vpenades

Typically, the usual way of accessing the contents of an archive, both with System.IO.Compression and with SharpCompress is to open the archive stream, and use the stream to browse the contents of the archive.

This approach expect burst operations: Open -> heavy read/writes -> Close

Now I have the requirement of accessing specific files within many archives, randomly, over time.

Keeping the archives streams open is not practical because amongst other things, it requires resource management (disposing the streams)

So as a first approach, I built a framework on top of SharpCompress that does this:

  • Open an archive
  • read the TOC and gather all the entries in a new structure for each entry.
  • Close the archive

Them when I need to access a file archive at random, I use the structure for the archive entry, which:

  • opens the stream
  • finds the entry
  • opens the archive entry
  • returns a stream that, when closed, it will also close the archive stream.

This works well except for one detail: every time I open an entry it has the overhead of reading the complete TOC of the archive or seek through the archive back and forth.

So my question is: Could it be possible to introduce a new reading API so file entries contain all the internal information so when opened, can go straight away to the location where the specific entry is located, and read it, without requiring to reprocess the whole archive?

I've attempted successfully to do it with ZIP archives and it works just fine, but I am aware that this would not be doable for all archive types

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions