/** * Returns the parent of this directory. If this directory has been deleted, this returns the * directory it was in when it was deleted. */ public Directory parent() { return entryInParent.directory(); }
@Override void linked(DirectoryEntry entry) { File parent = entry.directory(); // handles null check this.entryInParent = entry; forcePut(new DirectoryEntry(this, Name.PARENT, parent)); }
/** * Gets the {@linkplain Path#toRealPath(LinkOption...) real path} to the file located by the * given path. */ public JimfsPath toRealPath( JimfsPath path, PathService pathService, Set<? super LinkOption> options) throws IOException { checkNotNull(path); checkNotNull(options); store.readLock().lock(); try { DirectoryEntry entry = lookUp(path, options).requireExists(path); List<Name> names = new ArrayList<>(); names.add(entry.name()); while (!entry.file().isRootDirectory()) { entry = entry.directory().entryInParent(); names.add(entry.name()); } // names are ordered last to first in the list, so get the reverse view List<Name> reversed = Lists.reverse(names); Name root = reversed.remove(0); return pathService.createPath(root, reversed); } finally { store.readLock().unlock(); } }
/** * Deletes the given directory entry from its parent directory. */ private void delete(DirectoryEntry entry, DeleteMode deleteMode, JimfsPath pathForException) throws IOException { Directory parent = entry.directory(); File file = entry.file(); checkDeletable(file, deleteMode, pathForException); parent.unlink(entry.name()); parent.updateModifiedTime(); file.deleted(); }
Directory parent = entry.directory();
lookUp(link, Options.NOFOLLOW_LINKS).requireDoesNotExist(link).directory();
/** * Returns the parent of this directory. If this directory has been deleted, this returns the * directory it was in when it was deleted. */ public Directory parent() { return entryInParent.directory(); }
@Override void linked(DirectoryEntry entry) { File parent = entry.directory(); // handles null check this.entryInParent = entry; forcePut(new DirectoryEntry(this, Name.PARENT, parent)); }
/** * Gets the {@linkplain Path#toRealPath(LinkOption...) real path} to the file located by the * given path. */ public JimfsPath toRealPath( JimfsPath path, PathService pathService, Set<? super LinkOption> options) throws IOException { checkNotNull(path); checkNotNull(options); store.readLock().lock(); try { DirectoryEntry entry = lookUp(path, options).requireExists(path); List<Name> names = new ArrayList<>(); names.add(entry.name()); while (!entry.file().isRootDirectory()) { entry = entry.directory().entryInParent(); names.add(entry.name()); } // names are ordered last to first in the list, so get the reverse view List<Name> reversed = Lists.reverse(names); Name root = reversed.remove(0); return pathService.createPath(root, reversed); } finally { store.readLock().unlock(); } }
/** * Deletes the given directory entry from its parent directory. */ private void delete(DirectoryEntry entry, DeleteMode deleteMode, JimfsPath pathForException) throws IOException { Directory parent = entry.directory(); File file = entry.file(); checkDeletable(file, deleteMode, pathForException); parent.unlink(entry.name()); parent.updateModifiedTime(); file.deleted(); }
Directory parent = entry.directory();
lookUp(link, Options.NOFOLLOW_LINKS).requireDoesNotExist(link).directory();