FileDocCategorySizeDatePackage
TarScanner.javaAPI DocApache Ant 1.703489Wed Dec 13 06:16:22 GMT 2006org.apache.tools.ant.types

TarScanner

public class TarScanner extends ArchiveScanner
Scans tar archives for resources.

Fields Summary
Constructors Summary
Methods Summary
protected voidfillMapsFromArchive(Resource src, java.lang.String encoding, java.util.Map fileEntries, java.util.Map matchFileEntries, java.util.Map dirEntries, java.util.Map matchDirEntries)
Fills the file and directory maps with resources read from the archive.

param
src the archive to scan.
param
encoding encoding used to encode file names inside the archive.
param
fileEntries Map (name to resource) of non-directory resources found inside the archive.
param
matchFileEntries Map (name to resource) of non-directory resources found inside the archive that matched all include patterns and didn't match any exclude patterns.
param
dirEntries Map (name to resource) of directory resources found inside the archive.
param
matchDirEntries Map (name to resource) of directory resources found inside the archive that matched all include patterns and didn't match any exclude patterns.

        TarEntry entry = null;
        TarInputStream ti = null;

        try {
            try {
                ti = new TarInputStream(src.getInputStream());
            } catch (IOException ex) {
                throw new BuildException("problem opening " + srcFile, ex);
            }
            while ((entry = ti.getNextEntry()) != null) {
                Resource r = new TarResource(src, entry);
                String name = entry.getName();
                if (entry.isDirectory()) {
                    name = trimSeparator(name);
                    dirEntries.put(name, r);
                    if (match(name)) {
                        matchDirEntries.put(name, r);
                    }
                } else {
                    fileEntries.put(name, r);
                    if (match(name)) {
                        matchFileEntries.put(name, r);
                    }
                }
            }
        } catch (IOException ex) {
            throw new BuildException("problem reading " + srcFile, ex);
        } finally {
            if (ti != null) {
                try {
                    ti.close();
                } catch (IOException ex) {
                    // swallow
                }
            }
        }