org.codehaus.plexus.util

Class Expand


public class Expand
extends java.lang.Object

Unzip a file.
Authors:
costin@dnt.ro
Stefan Bodewig
Magesh Umasankar
Since:
Ant 1.1 @ant.task category="packaging" name="unzip" name="unjar" name="unwar"

Field Summary

private File
dest
private boolean
overwrite
private File
source

Method Summary

void
execute()
Do the work.
protected void
expandFile(File srcF, File dir)
Description of the Method
protected void
extractFile(File srcF, File dir, InputStream compressedInputStream, String entryName, Date entryDate, boolean isDirectory)
Description of the Method
File
normalize(String path)
"normalize" the given absolute path.
File
resolveFile(File file, String filename)
Interpret the filename as a file relative to the given file - unless the filename already represents an absolute filename.
void
setDest(File d)
Set the destination directory.
void
setOverwrite(boolean b)
Should we overwrite files in dest, even if they are newer than the corresponding entries in the archive?
void
setSrc(File s)
Set the path to zip-file.

Field Details

dest

private File dest

overwrite

private boolean overwrite

source

private File source

Method Details

execute

public void execute()
            throws Exception
Do the work.

expandFile

protected void expandFile(File srcF,
                          File dir)
            throws Exception
Description of the Method

extractFile

protected void extractFile(File srcF,
                           File dir,
                           InputStream compressedInputStream,
                           String entryName,
                           Date entryDate,
                           boolean isDirectory)
            throws Exception
Description of the Method

normalize

public File normalize(String path)
"normalize" the given absolute path.

This includes:

  • Uppercase the drive letter if there is one.
  • Remove redundant slashes after the drive spec.
  • resolve all ./, .\, ../ and ..\ sequences.
  • DOS style paths that start with a drive letter will have \ as the separator.

resolveFile

public File resolveFile(File file,
                        String filename)
Interpret the filename as a file relative to the given file - unless the filename already represents an absolute filename.
Parameters:
file - the "reference" file for relative paths. This manager must be an absolute file and must not contain "./" or "../" sequences (same for \ instead of /). If it is null, this call is equivalent to new java.io.File(filename).
filename - a file name
Returns:
an absolute file that doesn't contain "./" or "../" sequences and uses the correct separator for the current platform.

setDest

public void setDest(File d)
Set the destination directory. File will be unzipped into the destination directory.
Parameters:
d - Path to the directory.

setOverwrite

public void setOverwrite(boolean b)
Should we overwrite files in dest, even if they are newer than the corresponding entries in the archive?

setSrc

public void setSrc(File s)
Set the path to zip-file.
Parameters:
s - Path to zip-file.