1 21 package proguard.io; 22 23 import proguard.classfile.ClassConstants; 24 25 import java.io.*; 26 27 32 public class FileDataEntry implements DataEntry 33 { 34 private File directory; 35 private File file; 36 private InputStream inputStream; 37 38 39 public FileDataEntry(File directory, 40 File file) 41 { 42 this.directory = directory; 43 this.file = file; 44 } 45 46 47 49 public String getName() 50 { 51 return file.equals(directory) ? 53 file.getName() : 54 file.getPath() 55 .substring(directory.getPath().length() + File.separator.length()) 56 .replace(File.separatorChar, ClassConstants.INTERNAL_PACKAGE_SEPARATOR); 57 } 58 59 60 62 public InputStream getInputStream() throws IOException 63 { 64 if (inputStream == null) 65 { 66 inputStream = new BufferedInputStream(new FileInputStream(file)); 67 } 68 69 return inputStream; 70 } 71 72 73 public void closeInputStream() throws IOException 74 { 75 inputStream.close(); 76 inputStream = null; 77 } 78 79 80 public DataEntry getParent() 81 { 82 return null; 83 } 84 85 86 88 public String toString() 89 { 90 return getName(); 91 } 92 } 93 | Popular Tags |