enhance ForDoAll

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1451 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
alfred 2006-09-05 05:52:57 +00:00
parent c8df018e44
commit 7deec1481c
3 changed files with 21 additions and 5 deletions

View File

@ -148,7 +148,9 @@ public final class Common {
File test; File test;
if (type == DIR || type == BOTH) { if (type == DIR || type == BOTH) {
fda.toDo(path); if (fda.dirFilter(path)) {
fda.run(path);
}
} }
for (int i = 0 ; i < list.length ; i++) { for (int i = 0 ; i < list.length ; i++) {
test = new File(path + File.separator + list[i]); test = new File(path + File.separator + list[i]);
@ -156,13 +158,19 @@ public final class Common {
toDoAll(path + File.separator + list[i], fda, type); toDoAll(path + File.separator + list[i], fda, type);
} else { } else {
if (type == FILE || type == BOTH) { if (type == FILE || type == BOTH) {
fda.toDo(path + File.separator + list[i]); if (fda.fileFilter(path + File.separator + list[i])) {
fda.run(path + File.separator + list[i]);
}
} }
} }
} }
} }
public static interface ForDoAll { public static interface ForDoAll {
public void toDo(String filepath) throws Exception; public void run(String filepath) throws Exception;
public boolean dirFilter(String filepath);
public boolean fileFilter(String filepath);
} }
} }

View File

@ -27,7 +27,7 @@ public final class Critic {
private static final int totallinelength = 82; private static final int totallinelength = 82;
public static final void run(String filepath) throws Exception { public static final void run(String filepath) throws Exception {
if (MigrationTool.doCritic) { if (MigrationTool.doCritic) { // this is left here to set an example for future structure
critic(filepath); critic(filepath);
} }
} }

View File

@ -27,7 +27,7 @@ public final class PathIterator implements Common.ForDoAll {
private HashSet<String> pathlist = new HashSet<String>(); private HashSet<String> pathlist = new HashSet<String>();
private Iterator<String> it = null; private Iterator<String> it = null;
public final void toDo(String path) throws Exception { public final void run(String path) throws Exception {
pathlist.add(path); pathlist.add(path);
} }
@ -42,4 +42,12 @@ public final class PathIterator implements Common.ForDoAll {
public final String toString() { public final String toString() {
return pathlist.toString(); return pathlist.toString();
} }
public boolean dirFilter(String filepath) {
return true;
}
public boolean fileFilter(String filepath) {
return true;
}
} }