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 TypeMethodDescriptionvoid
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.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
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 returnfalse
after 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
-