DirectoryWalker.java
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.fontengine.fontmanagement;
import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.List;
final class DirectoryWalker {
private List fileList;
private final boolean recurse;
DirectoryWalker(File r, boolean recurse) {
this.recurse = recurse;
if (r.isDirectory()) {
File[] list = r.listFiles(new FileFilter(){
public boolean accept(File file) {
return file.isFile() || file.isDirectory();
}
});
this.fileList = new ArrayList(list.length);
for (int i = 0; i < list.length; ++i) {
this.fileList.add(list[i]);
}
} else {
this.fileList = new ArrayList(1);
this.fileList.add(r);
}
}
File getNextFile() {
File nextFile;
do {
if (this.fileList.isEmpty()) {
return null;
}
nextFile = (File)this.fileList.remove(this.fileList.size() - 1);
if (!this.recurse || !nextFile.isDirectory()) continue;
File[] list = nextFile.listFiles();
for (int i = 0; i < list.length; ++i) {
this.fileList.add(list[i]);
}
return this.getNextFile();
} while (nextFile.isDirectory());
return nextFile;
}
}