1 18 19 package org.apache.tools.ant.types; 20 21 import java.io.IOException ; 22 import java.util.Map ; 23 24 import org.apache.tools.ant.BuildException; 25 import org.apache.tools.ant.types.resources.TarResource; 26 import org.apache.tools.tar.TarEntry; 27 import org.apache.tools.tar.TarInputStream; 28 29 32 public class TarScanner extends ArchiveScanner { 33 34 51 protected void fillMapsFromArchive(Resource src, String encoding, 52 Map fileEntries, Map matchFileEntries, 53 Map dirEntries, Map matchDirEntries) { 54 TarEntry entry = null; 55 TarInputStream ti = null; 56 57 try { 58 try { 59 ti = new TarInputStream(src.getInputStream()); 60 } catch (IOException ex) { 61 throw new BuildException("problem opening " + srcFile, ex); 62 } 63 while ((entry = ti.getNextEntry()) != null) { 64 Resource r = new TarResource(src, entry); 65 String name = entry.getName(); 66 if (entry.isDirectory()) { 67 name = trimSeparator(name); 68 dirEntries.put(name, r); 69 if (match(name)) { 70 matchDirEntries.put(name, r); 71 } 72 } else { 73 fileEntries.put(name, r); 74 if (match(name)) { 75 matchFileEntries.put(name, r); 76 } 77 } 78 } 79 } catch (IOException ex) { 80 throw new BuildException("problem reading " + srcFile, ex); 81 } finally { 82 if (ti != null) { 83 try { 84 ti.close(); 85 } catch (IOException ex) { 86 } 88 } 89 } 90 } 91 } 92 | Popular Tags |