Package net.sf.basedb.util.zip
Class ZipUnpacker
java.lang.Object
net.sf.basedb.util.zip.ZipUnpacker
This class can be used to unpack zip files into the BASE directory structure.
The class supports unpacking multiple zip files in the same transaction.
- Version:
- 2.0
- Author:
- nicklas
- Last modified
- $Date: 2011-09-23 09:05:23 +0200 (fr, 23 sep 2011) $
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate Directory
getDirectory
(Path path) Get the directory for the specified path.int
unpackZipFile
(Directory rootDir, ZipInputStream zip, File sourceFile, boolean overwrite, AbsoluteProgressReporter progress) Unpack a zip file.
-
Field Details
-
dc
-
paths
Cache of directories.
-
-
Constructor Details
-
ZipUnpacker
Create a new zip unpacker.- Parameters:
dc
- The DbControl to use for database access
-
-
Method Details
-
unpackZipFile
public int unpackZipFile(Directory rootDir, ZipInputStream zip, File sourceFile, boolean overwrite, AbsoluteProgressReporter progress) throws IOException, BaseException Unpack a zip file.- Parameters:
rootDir
- The directory where the contents of the zip file should be placedzip
- The contents of the zip fileoverwrite
- If existing files should be overwritten or ignoredprogress
- An optional progress reporter for displaying progress- Returns:
- The number of files unpacked
- Throws:
IOException
- If there is an error when unpacking the zip fileBaseException
- If there is a BASE error- Since:
- 3.0
-
getDirectory
Get the directory for the specified path. We first check the internal cache. If not found we try to load it from the database. If still not found we create a new directory and save it to the database.- Parameters:
path
- The path- Returns:
- The directory
-