1 25 26 package org.objectweb.jonas_lib.genbase.archive; 27 28 import java.io.File ; 29 import java.io.FileInputStream ; 30 import java.io.IOException ; 31 import java.io.InputStream ; 32 import java.util.List ; 33 import java.util.Vector ; 34 import java.util.jar.Manifest ; 35 36 import org.objectweb.jonas_lib.genbase.GenBaseException; 37 38 39 44 public class FileArchive extends AbsArchive { 45 46 53 public FileArchive(File archive) throws GenBaseException { 54 super(archive); 55 56 try { 57 File mf = new File (archive, "META-INF" + File.separator + "MANIFEST.MF"); 58 59 if (mf.exists()) { 60 setManifest(new Manifest (new FileInputStream (mf))); 61 } else { 62 setManifest(new Manifest ()); 63 } 64 } catch (Exception e) { 65 String err = getI18n().getMessage("FileArchive.constr.manifest", getRootFile()); 66 throw new GenBaseException(err, e); 67 } 68 } 69 70 80 public InputStream getInputStream(String filename) throws IOException { 81 File file = (File ) getFiles().get(filename); 82 83 if (file == null) { 84 file = new File (getRootFile(), filename); 87 88 if (!file.exists()) { 89 return null; 90 } 91 } 92 93 return new FileInputStream (file); 95 } 96 97 103 public List getContainedFiles() { 104 List list = new Vector (getFiles().keySet()); 105 106 traverse("", getRootFile(), list); 108 109 return list; 110 } 111 112 119 private static void traverse(String dirName, File base, List map) { 120 File [] childs = base.listFiles(); 121 122 if (childs != null) { 124 for (int i = 0; i < childs.length; i++) { 125 if (childs[i].isFile()) { 126 map.add(dirName + childs[i].getName()); 128 } else { 129 traverse(dirName + childs[i].getName() + File.separator, childs[i], map); 131 } 132 } 133 } 134 } 135 136 141 public boolean isPacked() { 142 return false; 143 } 144 } | Popular Tags |