@Override public boolean isSymlink() { if(!isSymlinkSet) { isSymlink = file.isSymlink(); isSymlinkSet = true; } return isSymlink; }
@Override public boolean isSymlink() { return file.isSymlink(); }
/** * <b>Implementation notes:</b> returns <code>false</code> (no caching) for: * <ul> * <li>local files: their icons are cached by the Swing component that provides icons.</li> * <li>symlinks: their icon cannot be cached using the file's extension as a key.</li> * </ul> * <code>true</code> is returned for non-local files that are not symlinks to avoid excessive temporary file * creation. */ public boolean isCacheable(AbstractFile file, Dimension preferredResolution) { return !((file.getTopAncestor() instanceof LocalFile) || file.isSymlink()); }
private AbstractFile resolveSymlink(AbstractFile file, Set<AbstractFile> visitedFiles) { if (visitedFiles.contains(file)) return null; else { visitedFiles.add(file); return file.isSymlink() ? resolveSymlink(file.getCanonicalFile(), visitedFiles) : file; } }
/** * 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(); }
/** * Pre-fetch the attributes that are used by the table renderer and some actions from the given CachedFile. * By doing so, the attributes will be available when the associated getters are called and thus the methods won't * be I/O bound and will not lock. * * @param cachedFile a CachedFile instance from which to pre-fetch attributes */ private static void prefetchCachedFileAttributes(AbstractFile cachedFile) { cachedFile.isDirectory(); cachedFile.isBrowsable(); cachedFile.isHidden(); // Pre-fetch isSymlink attribute and if the file is a symlink, pre-fetch the canonical file and its attributes if(cachedFile.isSymlink()) { AbstractFile canonicalFile = cachedFile.getCanonicalFile(); if(canonicalFile!=cachedFile) // Cheap test to prevent infinite recursion on bogus file implementations prefetchCachedFileAttributes(canonicalFile); } }
private static int getColorIndex(int row, AbstractFile file, FileTableModel tableModel) { // Parent directory. if(row==0 && tableModel.hasParentFolder()) return ThemeCache.FOLDER; // Marked file. if(tableModel.isRowMarked(row)) return ThemeCache.MARKED; // Symlink. if(file.isSymlink()) return ThemeCache.SYMLINK; // Hidden file. if(file.isHidden()) return ThemeCache.HIDDEN_FILE; // Directory. if(file.isDirectory()) return ThemeCache.FOLDER; // Archive. if(file.isBrowsable()) return ThemeCache.ARCHIVE; // Plain file. return ThemeCache.PLAIN_FILE; }
public boolean accept(AbstractFile file) { switch(attribute) { case DIRECTORY: return file.isDirectory(); case FILE: return !file.isDirectory(); case BROWSABLE: return file.isBrowsable(); case ARCHIVE: return file.isArchive(); case SYMLINK: return file.isSymlink(); case HIDDEN: return file.isHidden(); case ROOT: return file.isRoot(); case SYSTEM: return file.isSystem(); default: return true; } } }
if (file.isSymlink()) { resolvedFile = resolveSymlink(file); if (resolvedFile == null) {
/** * Asserts that a file can be renamed to a filename variation of the same file. * * @throws IOException should not normally happen * @throws NoSuchAlgorithmException should not happen */ @Test public void testRenameToCaseVariation() throws IOException, NoSuchAlgorithmException { // First test with a regular file createFile(tempFile, 1); AbstractFile destFile = tempFile.getParent().getDirectChild(tempFile.getName().toUpperCase()); deleteWhenFinished(destFile); tempFile.renameTo(destFile); assert !destFile.isSymlink(); // Leave me // Repeat the test with a directory destFile.delete(); tempFile.mkdir(); tempFile.renameTo(destFile); assert !destFile.isSymlink(); // Leave me }
/** * <i>Implementation note:</i> only one resolution is available (usually 16x16) and blindly returned, the * <code>preferredResolution</code> argument is simply ignored. */ @Override public Icon getLocalFileIcon(LocalFile localFile, AbstractFile originalFile, Dimension preferredResolution) { // Initialize the Swing object the first time this method is called checkInit(); // Retrieve the icon using the Swing provider component Icon icon = getSwingIcon((java.io.File)localFile.getUnderlyingFileObject()); // Add a symlink indication to the icon if: // - the original file is a symlink AND // - the original file is not a local file OR // - the original file is a local file but the Swing component generates icons which do not have a symlink // indication. That is the case on Mac OS X 10.5 (regression, 10.4 did this just fine). // // Note that the symlink test is performed last because it is the most expensive. // if((!(originalFile.getTopAncestor() instanceof LocalFile) || (OsFamily.MAC_OS_X.isCurrent() && OsVersion.MAC_OS_X_10_5.isCurrent())) && originalFile.isSymlink()) { icon = getSymlinkIcon(icon); } return icon; } }
if(!file.isSymlink()) { do { // Loop for retry
if (file.isDirectory() && !file.isSymlink()) { nbFolders++;
if (file.isDirectory() && !file.isSymlink()) {
s += isSymlink()?'l':isDirectory()?'d':'-';
boolean isSymlink = file.isSymlink(); if(isSymlink) file = file.getCanonicalFile();
if(sourceFile.isSymlink()) return;
if (file.isSymlink()) { resolvedFile = resolveSymlink(file);