Mercurial > jhg
comparison src/org/tmatesoft/hg/util/FileWalker.java @ 425:48f993aa2f41
FIXMEs: exceptions, javadoc
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 28 Mar 2012 18:39:29 +0200 |
parents | 7f27122011c3 |
children | 613c883e360e |
comparison
equal
deleted
inserted
replaced
424:6437d261048a | 425:48f993aa2f41 |
---|---|
18 | 18 |
19 import java.io.File; | 19 import java.io.File; |
20 import java.util.LinkedList; | 20 import java.util.LinkedList; |
21 import java.util.NoSuchElementException; | 21 import java.util.NoSuchElementException; |
22 | 22 |
23 import org.tmatesoft.hg.core.SessionContext; | |
23 import org.tmatesoft.hg.internal.Internals; | 24 import org.tmatesoft.hg.internal.Internals; |
24 | 25 |
25 /** | 26 /** |
26 * Implementation of {@link FileIterator} using regular {@link java.io.File} | 27 * Implementation of {@link FileIterator} using regular {@link java.io.File} |
27 * | 28 * |
34 private final Path.Source pathHelper; | 35 private final Path.Source pathHelper; |
35 private final LinkedList<File> dirQueue; | 36 private final LinkedList<File> dirQueue; |
36 private final LinkedList<File> fileQueue; | 37 private final LinkedList<File> fileQueue; |
37 private final Path.Matcher scope; | 38 private final Path.Matcher scope; |
38 private final boolean execCap, linkCap; | 39 private final boolean execCap, linkCap; |
40 private final SessionContext sessionContext; | |
39 private RegularFileInfo nextFile; | 41 private RegularFileInfo nextFile; |
40 private Path nextPath; | 42 private Path nextPath; |
41 | 43 |
42 public FileWalker(File dir, Path.Source pathFactory) { | 44 public FileWalker(SessionContext ctx, File dir, Path.Source pathFactory) { |
43 this(dir, pathFactory, null); | 45 this(ctx, dir, pathFactory, null); |
44 } | 46 } |
45 | 47 |
46 /** | 48 /** |
47 * | 49 * |
48 * @param dir | 50 * @param dir |
49 * @param pathFactory | 51 * @param pathFactory |
50 * @param scopeMatcher - this matcher shall be capable to tell not only files of interest, but | 52 * @param scopeMatcher - this matcher shall be capable to tell not only files of interest, but |
51 * also whether directories shall be traversed or not (Paths it gets in {@link Path.Matcher#accept(Path)} may | 53 * also whether directories shall be traversed or not (Paths it gets in {@link Path.Matcher#accept(Path)} may |
52 * point to directories) | 54 * point to directories) |
53 */ | 55 */ |
54 public FileWalker(File dir, Path.Source pathFactory, Path.Matcher scopeMatcher) { | 56 public FileWalker(SessionContext ctx, File dir, Path.Source pathFactory, Path.Matcher scopeMatcher) { |
57 sessionContext = ctx; | |
55 startDir = dir; | 58 startDir = dir; |
56 pathHelper = pathFactory; | 59 pathHelper = pathFactory; |
57 dirQueue = new LinkedList<File>(); | 60 dirQueue = new LinkedList<File>(); |
58 fileQueue = new LinkedList<File>(); | 61 fileQueue = new LinkedList<File>(); |
59 scope = scopeMatcher; | 62 scope = scopeMatcher; |
64 | 67 |
65 public void reset() { | 68 public void reset() { |
66 fileQueue.clear(); | 69 fileQueue.clear(); |
67 dirQueue.clear(); | 70 dirQueue.clear(); |
68 dirQueue.add(startDir); | 71 dirQueue.add(startDir); |
69 nextFile = new RegularFileInfo(supportsExecFlag(), supportsLinkFlag()); | 72 nextFile = new RegularFileInfo(sessionContext, supportsExecFlag(), supportsLinkFlag()); |
70 nextPath = null; | 73 nextPath = null; |
71 } | 74 } |
72 | 75 |
73 public boolean hasNext() { | 76 public boolean hasNext() { |
74 return fill(); | 77 return fill(); |