Package com.facebook.buck.io.filesystem
Interface ProjectFilesystemView
-
- All Known Implementing Classes:
DefaultProjectFilesystemView
public interface ProjectFilesystemView
A configured view over theProjectFilesystem
. All traversal operations on this filesystem behaves according configured ignored paths and according to the configured rootpath.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description com.google.common.collect.ImmutableCollection<Path>
getDirectoryContents(Path pathToUse)
Gets a list of paths of the contents of the given directory, obeying the ignores.com.google.common.collect.ImmutableSet<Path>
getFilesUnderPath(Path pathRelativeToProjectRoot, com.google.common.base.Predicate<Path> filter, EnumSet<FileVisitOption> visitOptions)
Returns a list of files under the given path relative to the root of this view, filtered both blacklist and the given filter.com.google.common.collect.ImmutableSet<Path>
getFilesUnderPath(Path pathRelativeToProjectRoot, EnumSet<FileVisitOption> visitOptions)
Path
getRootPath()
boolean
isDirectory(Path path)
boolean
isFile(Path path, LinkOption... options)
Checks whether there is a normal file at the specified pathboolean
isIgnored(Path path)
boolean
isSubdirOf(Path path)
<A extends BasicFileAttributes>
AreadAttributes(Path path, Class<A> type, LinkOption... options)
Read basic attributes of a file from a file systemPath
relativize(Path path)
Path
resolve(ForwardRelativePath path)
Path
resolve(String path)
Path
resolve(Path path)
com.google.common.collect.ImmutableList<String>
toWatchmanQuery(Set<Capability> capabilities)
void
walkFileTree(Path pathRelativeToProjectRoot, Set<FileVisitOption> options, FileVisitor<Path> fileVisitor)
Walks the filesystem starting at a given path relative to the root of this view, and all paths give tofileVisitor
is absolutevoid
walkRelativeFileTree(Path pathRelativeToProjectRoot, EnumSet<FileVisitOption> visitOptions, FileVisitor<Path> fileVisitor)
Similar towalkFileTree(Path, Set, FileVisitor)
fileVisitor receives paths relative to the root of this viewProjectFilesystemView
withView(Path newRelativeRoot, com.google.common.collect.ImmutableSet<PathMatcher> additionalIgnores)
void
writeLinesToPath(Iterable<String> lines, Path path, FileAttribute<?>... attrs)
-
-
-
Method Detail
-
isSubdirOf
boolean isSubdirOf(Path path)
- Parameters:
path
- an absolute path- Returns:
- true if path is a subdirectory of the root
-
relativize
Path relativize(Path path)
- Parameters:
path
- an absolute path to relativize- Returns:
- a relative path from the path root of this view to the given path
-
resolve
Path resolve(Path path)
- Parameters:
path
- the relative path to resolve- Returns:
- an absolute path of the given path relative to the root of this view
-
resolve
Path resolve(String path)
- See Also:
resolve(Path)
-
resolve
Path resolve(ForwardRelativePath path)
- See Also:
resolve(Path)
-
isFile
boolean isFile(Path path, LinkOption... options)
Checks whether there is a normal file at the specified path- Parameters:
path
- relative path to the rootoptions
- whether to resolve symlinks- Returns:
- true if path is a file
-
isDirectory
boolean isDirectory(Path path)
- Parameters:
path
- relative path to the root- Returns:
- true iff the given path maps to a directory
-
readAttributes
<A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... options) throws IOException
Read basic attributes of a file from a file system- Parameters:
path
- relative path to the roottype
- type of attributes objectoptions
- whether to resolve symlinks- Returns:
- File attributes object
- Throws:
IOException
-
getRootPath
Path getRootPath()
- Returns:
- the absolute path of the root of this view
-
withView
ProjectFilesystemView withView(Path newRelativeRoot, com.google.common.collect.ImmutableSet<PathMatcher> additionalIgnores)
- Parameters:
newRelativeRoot
- the new root relative to the current rootadditionalIgnores
- new ignored paths in addition to the current ignores- Returns:
- a new View based on the current view
-
isIgnored
boolean isIgnored(Path path)
- Parameters:
path
- an relative paths to the root of this filesystem view- Returns:
- whether the path is ignored by this view
-
walkRelativeFileTree
void walkRelativeFileTree(Path pathRelativeToProjectRoot, EnumSet<FileVisitOption> visitOptions, FileVisitor<Path> fileVisitor) throws IOException
Similar towalkFileTree(Path, Set, FileVisitor)
fileVisitor receives paths relative to the root of this view- Throws:
IOException
-
walkFileTree
void walkFileTree(Path pathRelativeToProjectRoot, Set<FileVisitOption> options, FileVisitor<Path> fileVisitor) throws IOException
Walks the filesystem starting at a given path relative to the root of this view, and all paths give tofileVisitor
is absolute- Throws:
IOException
-
getFilesUnderPath
com.google.common.collect.ImmutableSet<Path> getFilesUnderPath(Path pathRelativeToProjectRoot, EnumSet<FileVisitOption> visitOptions) throws IOException
- Throws:
IOException
-
getFilesUnderPath
com.google.common.collect.ImmutableSet<Path> getFilesUnderPath(Path pathRelativeToProjectRoot, com.google.common.base.Predicate<Path> filter, EnumSet<FileVisitOption> visitOptions) throws IOException
Returns a list of files under the given path relative to the root of this view, filtered both blacklist and the given filter. The returned paths are also relative to the root of this view.- Throws:
IOException
-
getDirectoryContents
com.google.common.collect.ImmutableCollection<Path> getDirectoryContents(Path pathToUse) throws IOException
Gets a list of paths of the contents of the given directory, obeying the ignores. All paths are relative to the root of this view.- Throws:
IOException
-
writeLinesToPath
void writeLinesToPath(Iterable<String> lines, Path path, FileAttribute<?>... attrs) throws IOException
- Parameters:
lines
- the lines to write to the file. Each item is written as one linepath
- the path relative to the view of this root to write the file. The parent of the path must existattrs
- theFileAttribute
s for the file created- Throws:
IOException
-
toWatchmanQuery
com.google.common.collect.ImmutableList<String> toWatchmanQuery(Set<Capability> capabilities)
-
-