1 21 package proguard.io; 22 23 import java.io.*; 24 25 26 32 public class DirectoryPump implements DataEntryPump 33 { 34 private File directory; 35 36 37 public DirectoryPump(File directory) 38 { 39 this.directory = directory; 40 } 41 42 43 45 public void pumpDataEntries(DataEntryReader dataEntryReader) 46 throws IOException 47 { 48 if (!directory.exists()) 49 { 50 throw new IOException("No such file or directory"); 51 } 52 53 readFiles(directory, dataEntryReader); 54 } 55 56 57 61 private void readFiles(File file, DataEntryReader dataEntryReader) 62 throws IOException 63 { 64 if (file.isDirectory()) 65 { 66 File[] files = file.listFiles(); 68 69 for (int index = 0; index < files.length; index++) 70 { 71 readFiles(files[index], dataEntryReader); 72 } 73 } 74 else 75 { 76 dataEntryReader.read(new FileDataEntry(directory, file)); 77 } 78 } 79 } 80 | Popular Tags |