213 public ClassFile getDirectory(String name) {
214 return getFile(name, true);
215 }
216
217 /**
218 * Load the specified file from the class path
219 */
220 public ClassFile getFile(String name) {
221 return getFile(name, false);
222 }
223
224 private final String fileSeparatorChar = "" + File.separatorChar;
225
226 private ClassFile getFile(String name, boolean isDirectory) {
227 String subdir = name;
228 String basename = "";
229 if (!isDirectory) {
230 int i = name.lastIndexOf(File.separatorChar);
231 subdir = name.substring(0, i + 1);
232 basename = name.substring(i + 1);
233 } else if (!subdir.equals("")
234 && !subdir.endsWith(fileSeparatorChar)) {
235 // zip files are picky about "foo" vs. "foo/".
236 // also, the getFiles caches are keyed with a trailing /
237 subdir = subdir + File.separatorChar;
238 name = subdir; // Note: isDirectory==true & basename==""
239 }
240 for (int i = 0; i < path.length; i++) {
241 ClassFile cf = path[i].getFile(name, subdir, basename, isDirectory);
242 if (cf != null) {
243 return cf;
244 }
245 }
246 return null;
247 }
248
249 /**
250 * Returns list of files given a package name and extension.
251 */
252 public Enumeration<ClassFile> getFiles(String pkg, String ext) {
253 Hashtable<String, ClassFile> files = new Hashtable<>();
|
213 public ClassFile getDirectory(String name) {
214 return getFile(name, true);
215 }
216
217 /**
218 * Load the specified file from the class path
219 */
220 public ClassFile getFile(String name) {
221 return getFile(name, false);
222 }
223
224 private final String fileSeparatorChar = "" + File.separatorChar;
225
226 private ClassFile getFile(String name, boolean isDirectory) {
227 String subdir = name;
228 String basename = "";
229 if (!isDirectory) {
230 int i = name.lastIndexOf(File.separatorChar);
231 subdir = name.substring(0, i + 1);
232 basename = name.substring(i + 1);
233 } else if (!subdir.isEmpty()
234 && !subdir.endsWith(fileSeparatorChar)) {
235 // zip files are picky about "foo" vs. "foo/".
236 // also, the getFiles caches are keyed with a trailing /
237 subdir = subdir + File.separatorChar;
238 name = subdir; // Note: isDirectory==true & basename==""
239 }
240 for (int i = 0; i < path.length; i++) {
241 ClassFile cf = path[i].getFile(name, subdir, basename, isDirectory);
242 if (cf != null) {
243 return cf;
244 }
245 }
246 return null;
247 }
248
249 /**
250 * Returns list of files given a package name and extension.
251 */
252 public Enumeration<ClassFile> getFiles(String pkg, String ext) {
253 Hashtable<String, ClassFile> files = new Hashtable<>();
|