mquigley avatar mquigley committed 8f5736f

Rather than simply deciding if we want to recursively iterate or not, let's use a maximum depth.

Comments (0)

Files changed (1)


     public void iterate(FilesystemPath path) throws FilesystemException {
-    	iterate(path, true);
+    	iterate(path, 0, -1);
-    public void iterate(FilesystemPath path, boolean recursive) throws FilesystemException {
+    public void iterate(FilesystemPath path, int maxDepth) {
+    	iterate(path, 0, maxDepth);
+    }
+    private void iterate(FilesystemPath path, int currentDepth, int maxDepth) throws FilesystemException {
     	File pathF = path.asFile();
     	if(pathF.exists() && pathF.canRead()) {
     			File[] contents = pathF.listFiles();
     			for(File f : contents) {
     				FilesystemPath fPath = new FilesystemPath(path).add(f.getName());
-    				if(recursive) {
-    					iterate(fPath, recursive);
+    				if(currentDepth < maxDepth || maxDepth == -1) {
+    					iterate(fPath, currentDepth + 1, maxDepth);
     				} else {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.