Mercurial > hg4j
diff src/org/tmatesoft/hg/util/FileWalker.java @ 141:8248aae33f7d
Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 17 Feb 2011 04:08:34 +0100 |
parents | f3c387ea0a34 |
children | 26ad7827a62d |
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/util/FileWalker.java Wed Feb 16 22:33:04 2011 +0100 +++ b/src/org/tmatesoft/hg/util/FileWalker.java Thu Feb 17 04:08:34 2011 +0100 @@ -25,16 +25,18 @@ * @author Artem Tikhomirov * @author TMate Software Ltd. */ -public class FileWalker { +public class FileWalker implements FileIterator { private final File startDir; + private final Path.Source pathHelper; private final LinkedList<File> dirQueue; private final LinkedList<File> fileQueue; private File nextFile; - private String nextPath; + private Path nextPath; - public FileWalker(File startDir) { - this.startDir = startDir; + public FileWalker(File dir, Path.Source pathFactory) { + startDir = dir; + pathHelper = pathFactory; dirQueue = new LinkedList<File>(); fileQueue = new LinkedList<File>(); reset(); @@ -57,10 +59,10 @@ throw new NoSuchElementException(); } nextFile = fileQueue.removeFirst(); - nextPath = path(nextFile); + nextPath = pathHelper.path(nextFile.getPath()); } - public String name() { + public Path name() { return nextPath; } @@ -68,12 +70,6 @@ return nextFile; } - private String path(File f) { - // XXX LocalHgRepo#normalize - String p = f.getPath().substring(startDir.getPath().length() + 1); - return p.replace('\\', '/').replace("//", "/"); - } - private File[] listFiles(File f) { // in case we need to solve os-related file issues (mac with some encodings?) return f.listFiles();