Class FileTreeIterator


  • public class FileTreeIterator
    extends WorkingTreeIterator
    Working directory iterator for standard Java IO.

    This iterator uses the standard java.io package to read the specified working directory as part of a TreeWalk.

    • Field Detail

      • directory

        protected final java.io.File directory
        the starting directory. This directory should correspond to the root of the repository.
      • fs

        protected final FS fs
        the file system abstraction which will be necessary to perform certain file system operations.
    • Constructor Detail

      • FileTreeIterator

        public FileTreeIterator​(Repository repo)
        Create a new iterator to traverse the work tree and its children.
        Parameters:
        repo - the repository whose working tree will be scanned.
      • FileTreeIterator

        public FileTreeIterator​(java.io.File root,
                                FS fs,
                                WorkingTreeOptions options)
        Create a new iterator to traverse the given directory and its children.
        Parameters:
        root - the starting directory. This directory should correspond to the root of the repository.
        fs - the file system abstraction which will be necessary to perform certain file system operations.
        options - working tree options to be used
      • FileTreeIterator

        protected FileTreeIterator​(WorkingTreeIterator p,
                                   java.io.File root,
                                   FS fs)
        Create a new iterator to traverse a subdirectory.
        Parameters:
        p - the parent iterator we were created from.
        fs - the file system abstraction which will be necessary to perform certain file system operations.
        root - the subdirectory. This should be a directory contained within the parent directory.
    • Method Detail

      • createSubtreeIterator

        public AbstractTreeIterator createSubtreeIterator​(ObjectReader reader)
                                                   throws IncorrectObjectTypeException,
                                                          java.io.IOException
        Description copied from class: AbstractTreeIterator
        Create a new iterator for the current entry's subtree.

        The parent reference of the iterator must be this, otherwise the caller would not be able to exit out of the subtree iterator correctly and return to continue walking this.

        Specified by:
        createSubtreeIterator in class AbstractTreeIterator
        Parameters:
        reader - reader to load the tree data from.
        Returns:
        a new parser that walks over the current subtree.
        Throws:
        IncorrectObjectTypeException - the current entry is not actually a tree and cannot be parsed as though it were a tree.
        java.io.IOException - a loose object or pack file could not be read.
      • getDirectory

        public java.io.File getDirectory()
        Returns:
        The root directory of this iterator
      • getEntryFile

        public java.io.File getEntryFile()
        Returns:
        The location of the working file. This is the same as new File(getDirectory(), getEntryPath()) but may be faster by reusing an internal File instance.