Class TarArchive

java.lang.Object
nl.knaw.dans.layerstore.TarArchive
All Implemented Interfaces:
Archive

public class TarArchive extends Object implements Archive
  • Constructor Details

    • TarArchive

      public TarArchive(@NonNull @NonNull Path tarFile)
  • Method Details

    • readFile

      public InputStream readFile(String filePath) throws IOException
      Description copied from interface: Archive
      Returns an input stream for the file at the given path. The caller is responsible for closing the stream.
      Specified by:
      readFile in interface Archive
      Parameters:
      filePath - the path of the file to read
      Returns:
      the input stream
      Throws:
      IOException - if an I/O error occurs
    • unarchiveTo

      public void unarchiveTo(Path stagingDir)
      Description copied from interface: Archive
      Unarchives the archive to the given staging directory. Note that the Archive.isArchived() will not return false after this operation, as the archive file is not removed.
      Specified by:
      unarchiveTo in interface Archive
      Parameters:
      stagingDir - the directory to unarchive to
    • archiveFrom

      public void archiveFrom(Path stagingDir)
      Description copied from interface: Archive
      Archives the given staging directory overwriting the backing file, if it exists. If this the archive is created successfully, Archive.isArchived() will return true.
      Specified by:
      archiveFrom in interface Archive
      Parameters:
      stagingDir - the directory to archive
    • isArchived

      public boolean isArchived()
      Description copied from interface: Archive
      Returns whether the archive has been created.
      Specified by:
      isArchived in interface Archive
      Returns:
      whether the archive has been created.
    • fileExists

      public boolean fileExists(String filePath)
      Description copied from interface: Archive
      Returns whether the file exists in the archive.
      Specified by:
      fileExists in interface Archive
      Parameters:
      filePath - the path of the file to check
      Returns:
      whether the file exists