FileDocCategorySizeDatePackage
Untar.javaAPI DocApache Ant 1.707370Wed Dec 13 06:16:18 GMT 2006org.apache.tools.ant.taskdefs

Untar

public class Untar extends Expand
Untar a file.

For JDK 1.1 "last modified time" field is set to current time instead of being carried from the archive file.

PatternSets are used to select files to extract from the archive. If no patternset is used, all files are extracted.

FileSet>s may be used to select archived files to perform unarchival upon.

File permissions will not be restored on extracted files.

The untar task recognizes the long pathname entries used by GNU tar.

since
Ant 1.1
ant.task
category="packaging"

Fields Summary
private UntarCompressionMethod
compression
compression method
Constructors Summary
Methods Summary
protected voidexpandFile(org.apache.tools.ant.util.FileUtils fileUtils, java.io.File srcF, java.io.File dir)
{@inheritDoc}

        FileInputStream fis = null;
        try {
            fis = new FileInputStream(srcF);
            expandStream(srcF.getPath(), fis, dir);
        } catch (IOException ioe) {
            throw new BuildException("Error while expanding " + srcF.getPath(),
                                     ioe, getLocation());
        } finally {
            FileUtils.close(fis);
        }
    
protected voidexpandResource(org.apache.tools.ant.types.Resource srcR, java.io.File dir)
This method is to be overridden by extending unarchival tasks.

param
srcR the source resource
param
dir the destination directory
since
Ant 1.7

        InputStream i = null;
        try {
            i = srcR.getInputStream();
            expandStream(srcR.getName(), i, dir);
        } catch (IOException ioe) {
            throw new BuildException("Error while expanding " + srcR.getName(),
                                     ioe, getLocation());
        } finally {
            FileUtils.close(i);
        }
    
private voidexpandStream(java.lang.String name, java.io.InputStream stream, java.io.File dir)

since
Ant 1.7

        TarInputStream tis = null;
        try {
            tis =
                new TarInputStream(compression.decompress(name,
                                                          new BufferedInputStream(stream)));
            log("Expanding: " + name + " into " + dir, Project.MSG_INFO);
            TarEntry te = null;
            FileNameMapper mapper = getMapper();
            while ((te = tis.getNextEntry()) != null) {
                extractFile(FileUtils.getFileUtils(), null, dir, tis,
                            te.getName(), te.getModTime(),
                            te.isDirectory(), mapper);
            }
            log("expand complete", Project.MSG_VERBOSE);
        } finally {
            FileUtils.close(tis);
        }
    
public voidsetCompression(org.apache.tools.ant.taskdefs.Untar$UntarCompressionMethod method)
Set decompression algorithm to use; default=none. Allowable values are
  • none - no compression
  • gzip - Gzip compression
  • bzip2 - Bzip2 compression

param
method compression method


                                          
        
        compression = method;
    
public voidsetEncoding(java.lang.String encoding)
No encoding support in Untar.

param
encoding not used
throws
BuildException always
since
Ant 1.6

        throw new BuildException("The " + getTaskName()
                                 + " task doesn't support the encoding"
                                 + " attribute", getLocation());