/** * Checks that this entry exists and links to a symbolic link, throwing an exception if not. * * @return this * @throws NoSuchFileException if this entry does not exist * @throws NotLinkException if this entry does not link to a symbolic link */ public DirectoryEntry requireSymbolicLink(Path pathForException) throws NoSuchFileException, NotLinkException { requireExists(pathForException); if (!file().isSymbolicLink()) { throw new NotLinkException(pathForException.toString()); } return this; }
/** * Looks up the last element of a path. */ @Nullable private DirectoryEntry lookUpLast( @Nullable File dir, Name name, Set<? super LinkOption> options, int linkDepth) throws IOException { Directory directory = toDirectory(dir); if (directory == null) { return null; } DirectoryEntry entry = directory.get(name); if (entry == null) { return new DirectoryEntry(directory, name, null); } File file = entry.file(); if (!options.contains(LinkOption.NOFOLLOW_LINKS) && file.isSymbolicLink()) { return followSymbolicLink(dir, (SymbolicLink) file, linkDepth); } return getRealEntry(entry); }
if (file.isSymbolicLink()) { DirectoryEntry linkResult = followSymbolicLink(dir, (SymbolicLink) file, linkDepth);
@Override public Object get(File file, String attribute) { switch (attribute) { case "size": return file.size(); case "fileKey": return file.id(); case "isDirectory": return file.isDirectory(); case "isRegularFile": return file.isRegularFile(); case "isSymbolicLink": return file.isSymbolicLink(); case "isOther": return !file.isDirectory() && !file.isRegularFile() && !file.isSymbolicLink(); case "creationTime": return FileTime.fromMillis(file.getCreationTime()); case "lastAccessTime": return FileTime.fromMillis(file.getLastAccessTime()); case "lastModifiedTime": return FileTime.fromMillis(file.getLastModifiedTime()); default: return null; } }
protected Attributes(File file) { this.lastModifiedTime = FileTime.fromMillis(file.getLastModifiedTime()); this.lastAccessTime = FileTime.fromMillis(file.getLastAccessTime()); this.creationTime = FileTime.fromMillis(file.getCreationTime()); this.regularFile = file.isRegularFile(); this.directory = file.isDirectory(); this.symbolicLink = file.isSymbolicLink(); this.size = file.size(); this.fileKey = file.id(); }
/** * Checks that this entry exists and links to a symbolic link, throwing an exception if not. * * @return this * @throws NoSuchFileException if this entry does not exist * @throws NotLinkException if this entry does not link to a symbolic link */ public DirectoryEntry requireSymbolicLink(Path pathForException) throws NoSuchFileException, NotLinkException { requireExists(pathForException); if (!file().isSymbolicLink()) { throw new NotLinkException(pathForException.toString()); } return this; }
/** * Looks up the last element of a path. */ @Nullable private DirectoryEntry lookUpLast( @Nullable File dir, Name name, Set<? super LinkOption> options, int linkDepth) throws IOException { Directory directory = toDirectory(dir); if (directory == null) { return null; } DirectoryEntry entry = directory.get(name); if (entry == null) { return new DirectoryEntry(directory, name, null); } File file = entry.file(); if (!options.contains(LinkOption.NOFOLLOW_LINKS) && file.isSymbolicLink()) { return followSymbolicLink(dir, (SymbolicLink) file, linkDepth); } return getRealEntry(entry); }
if (file.isSymbolicLink()) { DirectoryEntry linkResult = followSymbolicLink(dir, (SymbolicLink) file, linkDepth);
@Override public Object get(File file, String attribute) { switch (attribute) { case "size": return file.size(); case "fileKey": return file.id(); case "isDirectory": return file.isDirectory(); case "isRegularFile": return file.isRegularFile(); case "isSymbolicLink": return file.isSymbolicLink(); case "isOther": return !file.isDirectory() && !file.isRegularFile() && !file.isSymbolicLink(); case "creationTime": return FileTime.fromMillis(file.getCreationTime()); case "lastAccessTime": return FileTime.fromMillis(file.getLastAccessTime()); case "lastModifiedTime": return FileTime.fromMillis(file.getLastModifiedTime()); default: return null; } }
protected Attributes(File file) { this.lastModifiedTime = FileTime.fromMillis(file.getLastModifiedTime()); this.lastAccessTime = FileTime.fromMillis(file.getLastAccessTime()); this.creationTime = FileTime.fromMillis(file.getCreationTime()); this.regularFile = file.isRegularFile(); this.directory = file.isDirectory(); this.symbolicLink = file.isSymbolicLink(); this.size = file.size(); this.fileKey = file.id(); }