/** * Creates list of files in a given directory, including all its subdirectories. * * @return <code>Collection</code> of <code>File</code> objects in the given directory, * including all its subdirectories. * @param filesDir * The given directory. * * @exception java.io.IOException * If any I/O exception occurs. */ public static Collection<File> createFileList(File filesDir) throws IOException { return createFileList(filesDir, 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)); }
/** * Creates list of files in a given directory. If a given <code>boolean</code> flag is * <code>true</code>, all the sub-directories of the given directory are also scanned, * otherwise only files in the given directory are included. * * @return <code>Collection</code> of <code>File</code> objects in the given directory. * @param filesDir * The given directory. * @param includeSubdirs * If <code>true</code>, the returned file list includes files from all the * sub-directories of the given directory, otherwise it includes only files from the * given directory itself. * * @exception java.io.IOException * If any I/O exception occurs. */ public static Collection<File> createFileList(File filesDir, boolean includeSubdirs) throws IOException { ArrayList<File> listOfFiles = new ArrayList<File>(); File[] allDirFiles = filesDir.listFiles(); if (allDirFiles == null) throw new FileNotFoundException("invalid directory specified"); for (int i = 0; i < allDirFiles.length; i++) { File aFile = allDirFiles[i]; if (aFile.isDirectory() && includeSubdirs) listOfFiles.addAll(createFileList(aFile, includeSubdirs)); else if (!aFile.isDirectory()) listOfFiles.add(aFile); } return listOfFiles; }
Collection<File> fileList = FileUtil.createFileList(libDir); Iterator<File> files = fileList.iterator(); while (files.hasNext()) {
Collection<File> fileList = createFileList(directory, false); SortedSet<File> sortedFileSet = sortFileListByTime(fileList); if (sortedFileSet.size() > maxLimit) {
Collection<File> confDirFiles = FileUtil.createFileList(confDir, false); File descDir = new File(_mainRootDir, InstallationController.PACKAGE_DESC_DIR); Collection<File> descDirFiles = FileUtil.createFileList(descDir, false); File[] fileList = new File[confDirFiles.size() + descDirFiles.size()]; int fileCounter = 0;
if (!targetDir.isDirectory()) return; Iterator fileList = FileUtil.createFileList(targetDir, true).iterator(); while (fileList.hasNext()) { File file = (File) fileList.next();
Iterator<File> fileList = FileUtil.createFileList(dir, true).iterator(); while (fileList.hasNext()) { File file = fileList.next();