diff src/org/tmatesoft/hg/util/FileWalker.java @ 287:ed6b74a58c66

Use FileInfo abstraction with necessary subset of File functionality instead of File to facilitate other effective file system iterators
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 07 Sep 2011 09:33:27 +0200
parents 1ec6b327a6ac
children 7f27122011c3
line wrap: on
line diff
--- a/src/org/tmatesoft/hg/util/FileWalker.java	Sat Sep 03 22:06:16 2011 +0200
+++ b/src/org/tmatesoft/hg/util/FileWalker.java	Wed Sep 07 09:33:27 2011 +0200
@@ -32,7 +32,7 @@
 	private final LinkedList<File> dirQueue;
 	private final LinkedList<File> fileQueue;
 	private final Path.Matcher scope;
-	private File nextFile;
+	private RegularFileInfo nextFile;
 	private Path nextPath;
 
 	public FileWalker(File dir, Path.Source pathFactory) {
@@ -60,7 +60,7 @@
 		fileQueue.clear();
 		dirQueue.clear();
 		dirQueue.add(startDir);
-		nextFile = null;
+		nextFile = new RegularFileInfo();
 		nextPath = null;
 	}
 	
@@ -72,15 +72,16 @@
 		if (!fill()) {
 			throw new NoSuchElementException();
 		}
-		nextFile = fileQueue.removeFirst();
-		nextPath = pathHelper.path(nextFile.getPath());
+		File next = fileQueue.removeFirst();
+		nextFile.init(next);
+		nextPath = pathHelper.path(next.getPath());
 	}
 
 	public Path name() {
 		return nextPath;
 	}
 	
-	public File file() {
+	public FileInfo file() {
 		return nextFile;
 	}