Interface Archive

All Known Implementing Classes:
DmfTarArchive, TarArchive, ZipArchive

public interface Archive
An archive is a file that contains a collection of files and directories. It can be implemented as a zip file, a tar, etc.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    archiveFrom(Path stagingDir)
    Archives the given staging directory overwriting the backing file, if it exists.
    boolean
    fileExists(String filePath)
    Returns whether the file exists in the archive.
    boolean
    Returns whether the archive has been created.
    readFile(String filePath)
    Returns an input stream for the file at the given path.
    void
    unarchiveTo(Path stagingDir)
    Unarchives the archive to the given staging directory.
  • Method Details

    • readFile

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

      void unarchiveTo(Path stagingDir)
      Unarchives the archive to the given staging directory. Note that the isArchived() will not return false after this operation, as the archive file is not removed.
      Parameters:
      stagingDir - the directory to unarchive to
    • archiveFrom

      void archiveFrom(Path stagingDir)
      Archives the given staging directory overwriting the backing file, if it exists. If this the archive is created successfully, isArchived() will return true.
      Parameters:
      stagingDir - the directory to archive
    • isArchived

      boolean isArchived()
      Returns whether the archive has been created.
      Returns:
      whether the archive has been created.
    • fileExists

      boolean fileExists(String filePath)
      Returns whether the file exists in the archive.
      Parameters:
      filePath - the path of the file to check
      Returns:
      whether the file exists