@Override protected AbstractFile[] getFiles(AbstractFile directory) throws IOException { return directory.ls(); } }
@Override public AbstractFile[] ls(FileFilter filter) throws IOException, UnsupportedFileOperationException { return file.ls(filter); }
@Override public AbstractFile[] ls() throws IOException, UnsupportedFileOperationException { return file.ls(); }
@Override public AbstractFile[] ls(FilenameFilter filter) throws IOException, UnsupportedFileOperationException { return file.ls(filter); }
/** * Return trash files count * <p> * We assume the count of items in trash equals the count of files in * <code>TRASH_PATH + "/info"</code> folder. * * @return Count of files in trash */ @Override public int getItemCount() { // Abort if there is no usable trash folder if(TRASH_FOLDER==null) return -1; try { return TRASH_INFO_SUBFOLDER.ls().length; } catch (java.io.IOException ex) { // can't access trash folder return -1; } }
/** * Return trash files count * <p> * We assume the count of items in trash equals the count of files in * <code>TRASH_PATH + "/info"</code> folder. * * @return Count of files in trash */ @Override public int getItemCount() { // Abort if there is no usable trash folder if(TRASH_FOLDER==null) return -1; try { return TRASH_INFO_SUBFOLDER.ls().length; } catch (java.io.IOException ex) { // can't access trash folder return -1; } }
/** * Returns the children files that this file contains, filtering out files that do not match the specified FileFilter. * For this operation to be successful, this file must be 'browsable', i.e. {@link #isBrowsable()} must return * <code>true</code>. * * @param filter the FileFilter to be used to filter files out from the list, may be <code>null</code> * @return the children files that this file contains * @throws IOException if this operation is not possible (file is not browsable) or if an error occurred. * @throws UnsupportedFileOperationException if this method relies on a file operation that is not supported * or not implemented by the underlying filesystem. */ public AbstractFile[] ls(FileFilter filter) throws IOException, UnsupportedFileOperationException { return filter==null?ls():filter.filter(ls()); }
/** * Returns the children files that this file contains, filtering out files that do not match the specified FilenameFilter. * For this operation to be successful, this file must be 'browsable', i.e. {@link #isBrowsable()} must return * <code>true</code>. * * <p>This default implementation filters out files *after* they have been created. This method * should be overridden if a more efficient implementation can be provided by subclasses.</p> * * @param filter the FilenameFilter to be used to filter out files from the list, may be <code>null</code> * @return the children files that this file contains * @throws IOException if this operation is not possible (file is not browsable) or if an error occurred. * @throws UnsupportedFileOperationException if this method relies on a file operation that is not supported * or not implemented by the underlying filesystem. */ public AbstractFile[] ls(FilenameFilter filter) throws IOException, UnsupportedFileOperationException { return filter==null?ls():filter.filter(ls()); }
@Override public AbstractFile[] ls(FileFilter filter) throws IOException, UnsupportedFileOperationException { // Don't cache ls() result but create a CachedFile instance around each of the files if recursion is enabled AbstractFile files[] = file.ls(filter); if(recurseInstances) return createCachedFiles(files); return files; }
@Override protected AbstractFile[] getFiles(AbstractFile directory) throws IOException { return fileFilter.filter(directory.ls()); } }
/** * Returns the wrapped file's descendants. * @return the wrapped file's descendants. * @throws IOException if an I/O error occurs. * @throws UnsupportedFileOperationException if this operation is not supported by the underlying filesystem, * or is not implemented. */ @Override public AbstractFile[] ls() throws IOException, UnsupportedFileOperationException { return getUnderlyingFile().ls(); }
@Override public AbstractFile[] ls(FilenameFilter filter) throws IOException, UnsupportedFileOperationException { // Don't cache ls() result but create a CachedFile instance around each of the files if recursion is enabled AbstractFile files[] = file.ls(filter); if(recurseInstances) return createCachedFiles(files); return files; } }
@Override public AbstractFile[] ls() throws IOException, UnsupportedFileOperationException { // Don't cache ls() result but create a CachedFile instance around each of the files if recursion is enabled AbstractFile files[] = file.ls(); if(recurseInstances) return createCachedFiles(files); return files; }
private static Iterator<String> getThemeNames(AbstractFile themeFolder) { AbstractFile[] files; Vector<String> names; try { files = themeFolder.ls(new ExtensionFilenameFilter(".xml")); names = new Vector<String>(); for (AbstractFile file : files) names.add(getThemeName(file)); return names.iterator(); } catch(Exception e) {return new Vector<String>().iterator();} }
/** * Tests {@link AbstractFile#ls()} when the operation is not supported. * * @throws IOException should not happen */ protected void testLsUnsupported() throws IOException { // Assert that #ls throws a proper UnsupportedFileOperationException when called UnsupportedFileOperationException e = null; try { tempFile.ls(); } catch(UnsupportedFileOperationException ex) { e = ex; } assertUnsupportedFileOperationException(e, FileOperation.LIST_CHILDREN); }
/** * Adds the given file to the FileSet if it's not a folder, recurses otherwise. */ private void recurseOnFolder(AbstractFile file, FileSet flattenedFiles) throws IOException { if(file.isDirectory() && !file.isSymlink()) { AbstractFile children[] = file.ls(); for (AbstractFile child : children) recurseOnFolder(child, flattenedFiles); } else { flattenedFiles.add(file); } }
/** * Deletes the given file. If the file is a directory, enclosing files are deleted recursively. * Symbolic links to directories are simply deleted, without deleting the contents of the linked directory. * * @param file the file to delete * @throws IOException if an error occurred while deleting a file or listing a directory's contents * @throws UnsupportedFileOperationException if this method relies on a file operation that is not supported * or not implemented by the underlying filesystem. */ protected final void deleteRecursively(AbstractFile file) throws IOException, UnsupportedFileOperationException { if(file.isDirectory() && !file.isSymlink()) { AbstractFile children[] = file.ls(); for (AbstractFile child : children) deleteRecursively(child); } file.delete(); }
/** * Adds all known extensions to the current classpath. * <p> * This method will create the following new classpath entries: * <ul> * <li>{@link #getExtensionsFolder()}</li>. * <li>All <code>JAR</code> files in {@link #getExtensionsFolder()}.</li> * </ul> * </p> * @throws IOException if the extensions folder is not accessible. */ public static void addExtensionsToClasspath() throws IOException { AbstractFile[] files; // Adds the extensions folder to the classpath. addToClassPath(getExtensionsFolder()); // Adds all JAR files contained by the extensions folder to the classpath. files = getExtensionsFolder().ls(new ExtensionFilenameFilter(".jar")); for (AbstractFile file : files) addToClassPath(file); }
/** * Looks for XML files in the specified folder recursively and tests them for well-formedness. * A <code>org.xml.sax.SAXException</code> is thrown when an error is encountered in one of the XML files, * even a recoverable one. Any archive contained in the folder will be searched for XML files. * * @param folder the folder in which to look for XML files recursively. * @throws IOException if a file or a folder couldn't be accessed * @throws SAXException if an error was found in one of the XML documents * @throws ParserConfigurationException if 'a serious configuration error' occurred in the XML parser */ private void testXMLFiles(AbstractFile folder) throws SAXException, IOException, ParserConfigurationException { AbstractFile children[] = folder.ls(); for (AbstractFile bhild : children) { if (bhild.isBrowsable()) testXMLFiles(bhild); else if ("xml".equals(bhild.getExtension())) testXMLDocument(bhild); } }
/** * Tests the given volume folder and assert certain properties that a volume folder should have. * * @param volume a volume folder * @throws IOException should not happen */ protected void testVolume(AbstractFile volume) throws IOException { // Test basic volume properties assert volume != null; assert volume.equals(volume.getVolume()); // Volumes may not always exist -- for instance, removable drives under Windows. if(volume.exists()) { // If the volume exists, it must be a directory assert volume.isDirectory(); // Assert that children of the volume are located on the volume (test the first children only) AbstractFile[] children = volume.ls(); if(children.length>0) assert volume.equals(children[0].getVolume()); } }