You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Vladislav Rassokhin (JIRA)" <ji...@apache.org> on 2014/11/07 15:33:34 UTC

[jira] [Commented] (COMPRESS-269) Common interface for SevenZFile and ArchiveInputStream

    [ https://issues.apache.org/jira/browse/COMPRESS-269?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14202089#comment-14202089 ] 

Vladislav Rassokhin commented on COMPRESS-269:
----------------------------------------------

At least simple SevenZFile to ArchiveInputStream wrapper:
{code:java}
public class SevenZArchiveInputStream extends ArchiveInputStream {
  private final SevenZFile mySevenZFile;

  public SevenZArchiveInputStream(@NotNull final File file) throws IOException {
    mySevenZFile = new SevenZFile(file);
  }
  public SevenZArchiveInputStream(@NotNull final SevenZFile file) {
    mySevenZFile = file;
  }

  @Override
  public ArchiveEntry getNextEntry() throws IOException {
    return mySevenZFile.getNextEntry();
  }

  @Override
  public int read(final byte[] b, final int off, final int len) throws IOException {
    return mySevenZFile.read(b, off, len);
  }

  @Override
  public void close() throws IOException {
    mySevenZFile.close();
    super.close(); // do nothing actually
  }
}
{code}

This does not have InputStream constructor, but at least you can use 7z archives where other ArchiveInputStream's used.

Maybe someone could include that into commons compress sources?

> Common interface for SevenZFile and ArchiveInputStream
> ------------------------------------------------------
>
>                 Key: COMPRESS-269
>                 URL: https://issues.apache.org/jira/browse/COMPRESS-269
>             Project: Commons Compress
>          Issue Type: Improvement
>          Components: Archivers
>    Affects Versions: 1.8
>            Reporter: Nick Burch
>            Priority: Minor
>             Fix For: 2.0
>
>
> Both SevenZFile and ArchiveInputStream (effectively) have a method on them:
> ArchiveEntry getNextEntry()
> However, they don't share a common interface or parent which defines this, so it isn't possible to write generic code which would work with either to read archive entries out
> For Apache Tika, it would be good if after our 7z specific opening code, we could then use common code to read out and process the archive entries no matter what the archive format was



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)