net.sf.jomic.tools
Class FileArchive

java.lang.Object
  extended by net.sf.jomic.tools.FileArchive

public class FileArchive
extends Object

An archive containing files. Currently supported formats are ZIP and RAR.

For hints and implementation details on various archive formats, see for example Marco Schmidt's list of archive file formats and archivers .

Author:
Thomas Aglassinger

Constructor Summary
FileArchive(File newFile)
           
 
Method Summary
 void extract(File targetDir, String[] fileNamesToExtract)
           
 void extract(File targetDir, String[] fileNamesToExtract, ProgressFrame progressFrame, long progressIncrement)
          Extract to targetDir all files in fileNamesToExtract.
 String getBaseName()
          Get the plain name of the archive file, without directory and suffix.
 String getFileType()
          Get the file type of the archive.
 String[] list()
           
 void removeExtracted(File targetDir)
          Attempt to remove all files that could have been extracted from the archive to targetDir .
 void setUnrarCommand(String newUnrarCommand)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileArchive

public FileArchive(File newFile)
            throws IOException
Throws:
IOException
Method Detail

setUnrarCommand

public void setUnrarCommand(String newUnrarCommand)

getBaseName

public String getBaseName()
Get the plain name of the archive file, without directory and suffix. Example: "/Users/me/Comics/blah.cbz" yields "blah".


getFileType

public String getFileType()
Get the file type of the archive.

Returns:
one of: FileTools.FORMAT_ZIP, FileTools.FORMAT_RAR, FileTools.FORMAT_PDF

extract

public void extract(File targetDir,
                    String[] fileNamesToExtract,
                    ProgressFrame progressFrame,
                    long progressIncrement)
             throws IOException,
                    InterruptedException
Extract to targetDir all files in fileNamesToExtract. If progressFrame is not null, advance its progress bar by progressIncrement for every file that is extracted.

Throws:
IOException
InterruptedException

extract

public void extract(File targetDir,
                    String[] fileNamesToExtract)
             throws IOException,
                    InterruptedException
Throws:
IOException
InterruptedException

list

public String[] list()
              throws IOException,
                     InterruptedException
Throws:
IOException
InterruptedException

removeExtracted

public void removeExtracted(File targetDir)
                     throws IOException,
                            InterruptedException
Attempt to remove all files that could have been extracted from the archive to targetDir . If a file cannot be removed, log a warning and continue.

Throws:
IOException
InterruptedException