Package net.sf.basedb.util.zip
Class ZipUnpacker
- java.lang.Object
-
- net.sf.basedb.util.zip.ZipUnpacker
-
public class ZipUnpacker extends Object
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) $
-
-
Constructor Summary
Constructors Constructor Description ZipUnpacker(DbControl dc)
Create a new zip unpacker.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private 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.
-
-
-
Constructor Detail
-
ZipUnpacker
public ZipUnpacker(DbControl dc)
Create a new zip unpacker.- Parameters:
dc
- The DbControl to use for database access
-
-
Method Detail
-
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
private Directory getDirectory(Path path)
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
-
-