Package nl.knaw.dans.layerstore
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 TypeMethodDescriptionvoidarchiveFrom(Path stagingDir) Archives the given staging directory overwriting the backing file, if it exists.booleanfileExists(String filePath) Returns whether the file exists in the archive.booleanReturns whether the archive has been created.Lists all items in the archive.Returns an input stream for the file at the given path.voidunarchiveTo(Path stagingDir) Unarchives the archive to the given staging directory.
-
Method Details
-
readFile
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
Unarchives the archive to the given staging directory. Note that theisArchived()will not returnfalseafter this operation, as the archive file is not removed.- Parameters:
stagingDir- the directory to unarchive to
-
archiveFrom
Archives the given staging directory overwriting the backing file, if it exists. If this the archive is created successfully,isArchived()will returntrue.- Parameters:
stagingDir- the directory to archive
-
isArchived
boolean isArchived()Returns whether the archive has been created.- Returns:
- whether the archive has been created.
-
fileExists
Returns whether the file exists in the archive.- Parameters:
filePath- the path of the file to check- Returns:
- whether the file exists
-
listAllItems
Lists all items in the archive. The paths of the items are relative to the root of the archive. The iterator includes the root of the archive itself as a directory item with an empty path.- Returns:
- an iterator over all items in the archive
- Throws:
IOException
-