Package nl.knaw.dans.layerstore
Class ZipArchive
java.lang.Object
nl.knaw.dans.layerstore.ZipArchive
- All Implemented Interfaces:
Archive
Implementation of
Archive for ZIP archives.-
Constructor Summary
Constructors -
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.
-
Constructor Details
-
ZipArchive
-
-
Method Details
-
readFile
Description copied from interface:ArchiveReturns an input stream for the file at the given path. The caller is responsible for closing the stream.- Specified by:
readFilein interfaceArchive- Parameters:
filePath- the path of the file to read- Returns:
- the input stream
- Throws:
IOException- if an I/O error occurs
-
unarchiveTo
Description copied from interface:ArchiveUnarchives the archive to the given staging directory. Note that theArchive.isArchived()will not returnfalseafter this operation, as the archive file is not removed.- Specified by:
unarchiveToin interfaceArchive- Parameters:
stagingDir- the directory to unarchive to
-
archiveFrom
Description copied from interface:ArchiveArchives the given staging directory overwriting the backing file, if it exists. If this the archive is created successfully,Archive.isArchived()will returntrue.- Specified by:
archiveFromin interfaceArchive- Parameters:
stagingDir- the directory to archive
-
isArchived
public boolean isArchived()Description copied from interface:ArchiveReturns whether the archive has been created.- Specified by:
isArchivedin interfaceArchive- Returns:
- whether the archive has been created.
-
fileExists
Description copied from interface:ArchiveReturns whether the file exists in the archive.- Specified by:
fileExistsin interfaceArchive- Parameters:
filePath- the path of the file to check- Returns:
- whether the file exists
-
listAllItems
Description copied from interface:ArchiveLists 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.- Specified by:
listAllItemsin interfaceArchive- Returns:
- an iterator over all items in the archive
- Throws:
IOException
-