/** * Returns a snapshot mapping the names of each file in the directory at the given path to the * last modified time of that file. */ public ImmutableMap<Name, Long> snapshotModifiedTimes(JimfsPath path) throws IOException { ImmutableMap.Builder<Name, Long> modifiedTimes = ImmutableMap.builder(); store.readLock().lock(); try { Directory dir = (Directory) lookUp(path, Options.FOLLOW_LINKS) .requireDirectory(path) .file(); // TODO(cgdecker): Investigate whether WatchServices should keep a reference to the actual // directory when SecureDirectoryStream is supported rather than looking up the directory // each time the WatchService polls for (DirectoryEntry entry : dir) { if (!entry.name().equals(Name.SELF) && !entry.name().equals(Name.PARENT)) { modifiedTimes.put(entry.name(), entry.file().getLastModifiedTime()); } } return modifiedTimes.build(); } finally { store.readLock().unlock(); } }
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(); }
@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; } }
/** * Returns a snapshot mapping the names of each file in the directory at the given path to the * last modified time of that file. */ public ImmutableMap<Name, Long> snapshotModifiedTimes(JimfsPath path) throws IOException { ImmutableMap.Builder<Name, Long> modifiedTimes = ImmutableMap.builder(); store.readLock().lock(); try { Directory dir = (Directory) lookUp(path, Options.FOLLOW_LINKS) .requireDirectory(path) .file(); // TODO(cgdecker): Investigate whether WatchServices should keep a reference to the actual // directory when SecureDirectoryStream is supported rather than looking up the directory // each time the WatchService polls for (DirectoryEntry entry : dir) { if (!entry.name().equals(Name.SELF) && !entry.name().equals(Name.PARENT)) { modifiedTimes.put(entry.name(), entry.file().getLastModifiedTime()); } } return modifiedTimes.build(); } finally { store.readLock().unlock(); } }
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(); }
@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; } }