Interface ProjectFilesystemView

  • All Known Implementing Classes:
    DefaultProjectFilesystemView

    public interface ProjectFilesystemView
    A configured view over the ProjectFilesystem. All traversal operations on this filesystem behaves according configured ignored paths and according to the configured rootpath.
    • 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
      • isFile

        boolean isFile​(Path path,
                       LinkOption... options)
        Checks whether there is a normal file at the specified path
        Parameters:
        path - relative path to the root
        options - 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 root
        type - type of attributes object
        options - 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 root
        additionalIgnores - 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
      • 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 to fileVisitor is absolute
        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 line
        path - the path relative to the view of this root to write the file. The parent of the path must exist
        attrs - the FileAttributes for the file created
        Throws:
        IOException
      • toWatchmanQuery

        com.google.common.collect.ImmutableList<String> toWatchmanQuery​(Set<Capability> capabilities)