public class DefaultProjectFilesystemView extends Object implements ProjectFilesystemView
Modifier and Type | Method and 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,
EnumSet<FileVisitOption> visitOptions) |
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.
|
Path |
getRootPath() |
boolean |
isDirectory(Path path) |
boolean |
isFile(Path path,
LinkOption... options)
Checks whether there is a normal file at the specified path
|
boolean |
isIgnored(Path path) |
boolean |
isSubdirOf(Path path) |
<A extends BasicFileAttributes> |
readAttributes(Path path,
Class<A> type,
LinkOption... options)
Read basic attributes of a file from a file system
|
Path |
relativize(Path path) |
Path |
resolve(ForwardRelativePath path) |
Path |
resolve(Path path) |
Path |
resolve(String 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 to
fileVisitor is absolute |
void |
walkRelativeFileTree(Path pathRelativeToProjectRoot,
EnumSet<FileVisitOption> visitOptions,
FileVisitor<Path> fileVisitor)
Similar to
ProjectFilesystemView.walkFileTree(Path, Set, FileVisitor) fileVisitor receives paths relative to
the root of this view |
DefaultProjectFilesystemView |
withView(Path newRelativeRoot,
com.google.common.collect.ImmutableSet<PathMatcher> additionalIgnores) |
void |
writeLinesToPath(Iterable<String> lines,
Path path,
FileAttribute<?>... attrs) |
public com.google.common.collect.ImmutableList<String> toWatchmanQuery(Set<Capability> capabilities)
toWatchmanQuery
in interface ProjectFilesystemView
public boolean isSubdirOf(Path path)
isSubdirOf
in interface ProjectFilesystemView
path
- an absolute pathpublic Path relativize(Path path)
relativize
in interface ProjectFilesystemView
path
- an absolute path to relativizepublic Path resolve(Path path)
resolve
in interface ProjectFilesystemView
path
- the relative path to resolvepublic Path resolve(String path)
resolve
in interface ProjectFilesystemView
ProjectFilesystemView.resolve(Path)
public Path resolve(ForwardRelativePath path)
resolve
in interface ProjectFilesystemView
ProjectFilesystemView.resolve(Path)
public boolean isFile(Path path, LinkOption... options)
ProjectFilesystemView
isFile
in interface ProjectFilesystemView
path
- relative path to the rootoptions
- whether to resolve symlinkspublic boolean isDirectory(Path path)
isDirectory
in interface ProjectFilesystemView
path
- relative path to the rootpublic <A extends BasicFileAttributes> A readAttributes(Path path, Class<A> type, LinkOption... options) throws IOException
ProjectFilesystemView
readAttributes
in interface ProjectFilesystemView
path
- relative path to the roottype
- type of attributes objectoptions
- whether to resolve symlinksIOException
public Path getRootPath()
getRootPath
in interface ProjectFilesystemView
public DefaultProjectFilesystemView withView(Path newRelativeRoot, com.google.common.collect.ImmutableSet<PathMatcher> additionalIgnores)
withView
in interface ProjectFilesystemView
newRelativeRoot
- the new root relative to the current rootadditionalIgnores
- new ignored paths in addition to the current ignorespublic boolean isIgnored(Path path)
isIgnored
in interface ProjectFilesystemView
path
- an relative paths to the root of this filesystem viewpublic void walkRelativeFileTree(Path pathRelativeToProjectRoot, EnumSet<FileVisitOption> visitOptions, FileVisitor<Path> fileVisitor) throws IOException
ProjectFilesystemView
ProjectFilesystemView.walkFileTree(Path, Set, FileVisitor)
fileVisitor receives paths relative to
the root of this viewwalkRelativeFileTree
in interface ProjectFilesystemView
IOException
public void walkFileTree(Path pathRelativeToProjectRoot, Set<FileVisitOption> options, FileVisitor<Path> fileVisitor) throws IOException
ProjectFilesystemView
fileVisitor
is absolutewalkFileTree
in interface ProjectFilesystemView
IOException
public com.google.common.collect.ImmutableSet<Path> getFilesUnderPath(Path pathRelativeToProjectRoot, EnumSet<FileVisitOption> visitOptions) throws IOException
getFilesUnderPath
in interface ProjectFilesystemView
IOException
public com.google.common.collect.ImmutableSet<Path> getFilesUnderPath(Path pathRelativeToProjectRoot, com.google.common.base.Predicate<Path> filter, EnumSet<FileVisitOption> visitOptions) throws IOException
ProjectFilesystemView
getFilesUnderPath
in interface ProjectFilesystemView
IOException
public com.google.common.collect.ImmutableCollection<Path> getDirectoryContents(Path pathToUse) throws IOException
ProjectFilesystemView
getDirectoryContents
in interface ProjectFilesystemView
IOException
public void writeLinesToPath(Iterable<String> lines, Path path, FileAttribute<?>... attrs) throws IOException
writeLinesToPath
in interface ProjectFilesystemView
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
- the FileAttribute
s for the file createdIOException