Package io.roastedroot.zerofs
Class FileTree
java.lang.Object
io.roastedroot.zerofs.FileTree
The tree of directories and files for the file system. Contains the file system root directories
and provides the ability to look up files by path. One piece of the file store implementation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intDoesn't much matter, but this number comes from MIN_ELOOP_THRESHOLD hereMap of root names to root directories. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate DirectoryEntryfollowSymbolicLink(File dir, SymbolicLink link, int linkDepth) Returns the directory entry located by the target path of the given symbolic link, resolved relative to the given directory.private DirectoryEntrygetRealEntry(DirectoryEntry entry) Returns the entry for the file in its parent directory.Gets the directory entry for the root with the given name ornullif no such root exists.Returns the names of the root directories in this tree.private static booleanlookUp(File workingDirectory, ZeroFsPath path, Set<? super LinkOption> options) Returns the result of the file lookup for the given path.private DirectoryEntrylookUp(File dir, ZeroFsPath path, Set<? super LinkOption> options, int linkDepth) private DirectoryEntryLooks up the given names against the given base file.private DirectoryEntrylookUpLast(File dir, Name name, Set<? super LinkOption> options, int linkDepth) Looks up the last element of a path.private DirectorytoDirectory(File file)
-
Field Details
-
MAX_SYMBOLIC_LINK_DEPTH
private static final int MAX_SYMBOLIC_LINK_DEPTHDoesn't much matter, but this number comes from MIN_ELOOP_THRESHOLD here- See Also:
-
EMPTY_PATH_NAMES
-
roots
Map of root names to root directories.
-
-
Constructor Details
-
FileTree
Creates a new file tree with the given root directories.
-
-
Method Details
-
getRootDirectoryNames
Returns the names of the root directories in this tree. -
getRoot
Gets the directory entry for the root with the given name ornullif no such root exists. -
lookUp
public DirectoryEntry lookUp(File workingDirectory, ZeroFsPath path, Set<? super LinkOption> options) throws IOException Returns the result of the file lookup for the given path.- Throws:
IOException
-
lookUp
private DirectoryEntry lookUp(File dir, ZeroFsPath path, Set<? super LinkOption> options, int linkDepth) throws IOException - Throws:
IOException
-
lookUp
private DirectoryEntry lookUp(File dir, Iterable<Name> names, Set<? super LinkOption> options, int linkDepth) throws IOException Looks up the given names against the given base file. If the file is not a directory, the lookup fails.- Throws:
IOException
-
lookUpLast
private DirectoryEntry lookUpLast(File dir, Name name, Set<? super LinkOption> options, int linkDepth) throws IOException Looks up the last element of a path.- Throws:
IOException
-
followSymbolicLink
private DirectoryEntry followSymbolicLink(File dir, SymbolicLink link, int linkDepth) throws IOException Returns the directory entry located by the target path of the given symbolic link, resolved relative to the given directory.- Throws:
IOException
-
getRealEntry
Returns the entry for the file in its parent directory. This will be the given entry unless the name for the entry is "." or "..", in which the directory linking to the file is not the file's parent directory. In that case, we know the file must be a directory ("." and ".." can only link to directories), so we can just get the entry in the directory's parent directory that links to it. So, for example, if we have a directory "foo" that contains a directory "bar" and we find an entry [bar -> "." -> bar], we instead return the entry for bar in its parent, [foo -> "bar" -> bar]. -
toDirectory
-
isEmpty
-