/** * Creates list of subdirectories in a given root directory, including all its subdirectories. * * @param rootDir * The given root directory. * @return <code>Collection</code> of <code>File</code> objects, representing subdirectories * in the given root directory and all its subdirectories. * * @throws java.io.IOException * If any I/O exception occurs. */ public static Collection<File> createDirList(File rootDir) throws IOException { return createDirList(rootDir, true); }
/** * Constructor that allows browsing a given unacrhived PEAR package before or after its * installation. * * @param pearPackageDir * The root directory where the PEAR package was unarchived. * @throws IOException if a problem with IO */ public PackageBrowser(File pearPackageDir) throws IOException { _rootDir = pearPackageDir; _archived = false; // add directories and files to the lists _allFiles.addAll(FileUtil.createFileList(_rootDir, true)); _allDirs.addAll(FileUtil.createDirList(_rootDir, true)); }
/** * Constructor that allows browsing a given PEAR package without unarchiving it. * * @param pearPackage * The given archived PEAR package to browse. * @throws IOException if a problem with IO */ public PackageBrowser(JarFile pearPackage) throws IOException { _pearPackage = pearPackage; _pearFile = new File(pearPackage.getName()); int nameEndIndex = _pearFile.getAbsolutePath().lastIndexOf('.'); // set root dir = PEAR file path (w/o file name extension) String rootDirPath = (nameEndIndex > 0) ? _pearFile.getAbsolutePath() .substring(0, nameEndIndex) : _pearFile.getAbsolutePath(); _rootDir = new File(rootDirPath); _archived = true; // add directories and files to the lists _allDirs.addAll(FileUtil.createDirList(pearPackage)); _allFiles.addAll(FileUtil.createFileList(pearPackage)); }
listOfDirs.add(aFile); if (includeSubdirs) listOfDirs.addAll(createDirList(aFile, includeSubdirs));