func name changed & modify common.todoall
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1412 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
b315127350
commit
b678aacaa9
|
@ -60,7 +60,13 @@ public final class Common {
|
||||||
//-----------------------------------file&string---------------------------------------//
|
//-----------------------------------file&string---------------------------------------//
|
||||||
|
|
||||||
//--------------------------------------dir--------------------------------------------//
|
//--------------------------------------dir--------------------------------------------//
|
||||||
|
/*
|
||||||
|
public static final HashSet<String> walkDir(String path, int mode) throws Exception {
|
||||||
|
HashSet<String> pathlist = new HashSet<String>();
|
||||||
|
Common.toDoAll(path, Common.class.getMethod("walkDir", String.class), null, null, mode);
|
||||||
|
return pathlist;
|
||||||
|
}
|
||||||
|
*/
|
||||||
public static final void ensureDir(String objFileWhole) {
|
public static final void ensureDir(String objFileWhole) {
|
||||||
File tempdir;
|
File tempdir;
|
||||||
Matcher mtrseparate = ptnseparate.matcher(objFileWhole);
|
Matcher mtrseparate = ptnseparate.matcher(objFileWhole);
|
||||||
|
@ -137,21 +143,64 @@ public final class Common {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toDoAll(String path, ForDoAll fda) throws Exception { // filter of file type can be done in toDo
|
public static void toDoAll(String path, ForDoAll fda, int type) throws Exception { // filter of file type can be done in toDo
|
||||||
String[] list = new File(path).list();
|
String[] list = new File(path).list();
|
||||||
File test;
|
File test;
|
||||||
|
|
||||||
|
if (type == DIR || type == BOTH) {
|
||||||
|
fda.toDo(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]);
|
||||||
if (test.isDirectory()) {
|
if (test.isDirectory()) {
|
||||||
toDoAll(path + File.separator + list[i], fda);
|
toDoAll(path + File.separator + list[i], fda, type);
|
||||||
} else {
|
} else {
|
||||||
|
if (type == FILE || type == BOTH) {
|
||||||
fda.toDo(path + File.separator + list[i]);
|
fda.toDo(path + File.separator + list[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static interface ForDoAll {
|
public static interface ForDoAll {
|
||||||
public void toDo(String filepath) throws Exception;
|
public void toDo(String filepath) throws Exception;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
// this PathIterator is based on HashSet, an thread implementation is required.
|
||||||
|
private final class PathIterator implements ForDoAll{
|
||||||
|
PathIterator(String path) throws Exception {
|
||||||
|
startpath = path;
|
||||||
|
Common.toDoAll(startpath, this, mode);
|
||||||
|
}
|
||||||
|
PathIterator(String path, int md) throws Exception {
|
||||||
|
startpath = path;
|
||||||
|
mode = md;
|
||||||
|
Common.toDoAll(startpath, this, mode);
|
||||||
|
}
|
||||||
|
private String startpath;
|
||||||
|
private int mode = Common.BOTH;
|
||||||
|
private HashSet<String> pathlist = new HashSet<String>();
|
||||||
|
private Iterator<String> it = pathlist.iterator();
|
||||||
|
|
||||||
|
public final void toDo(String path) throws Exception {
|
||||||
|
pathlist.add(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String next() {
|
||||||
|
return it.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean hasNext() {
|
||||||
|
return it.hasNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String toString() {
|
||||||
|
return pathlist.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final PathIterator getPathIterator(String path, int md) throws Exception {
|
||||||
|
return new PathIterator(path, md);
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -184,7 +184,7 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList
|
||||||
if ( e.getSource() == goButton ) {
|
if ( e.getSource() == goButton ) {
|
||||||
try {
|
try {
|
||||||
logfile = new PrintWriter(new BufferedWriter(new FileWriter(startpath.replaceAll(Common.strseparate, "$1") + File.separator + "migration.log")));
|
logfile = new PrintWriter(new BufferedWriter(new FileWriter(startpath.replaceAll(Common.strseparate, "$1") + File.separator + "migration.log")));
|
||||||
MigrationTool.triger(startpath);
|
MigrationTool.startMigrateAll(startpath);
|
||||||
logfile.flush();
|
logfile.flush();
|
||||||
} catch (Exception en) {
|
} catch (Exception en) {
|
||||||
println(en.getMessage());
|
println(en.getMessage());
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class MigrationTool {
|
||||||
public static boolean doCritic = false;
|
public static boolean doCritic = false;
|
||||||
public static boolean defaultoutput = false;
|
public static boolean defaultoutput = false;
|
||||||
|
|
||||||
private static final void manipulate(ModuleInfo mi) throws Exception {
|
private static final void mainFlow(ModuleInfo mi) throws Exception {
|
||||||
|
|
||||||
ModuleReader.ModuleScan(mi);
|
ModuleReader.ModuleScan(mi);
|
||||||
//MigrationTool.ui.yesOrNo("go on replace?");
|
//MigrationTool.ui.yesOrNo("go on replace?");
|
||||||
|
@ -59,11 +59,11 @@ public class MigrationTool {
|
||||||
|
|
||||||
public static final void seekModule(String filepath) throws Exception {
|
public static final void seekModule(String filepath) throws Exception {
|
||||||
if (ModuleInfo.isModule(filepath)) {
|
if (ModuleInfo.isModule(filepath)) {
|
||||||
manipulate(new ModuleInfo(filepath));
|
mainFlow(new ModuleInfo(filepath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final void triger(String path) throws Exception {
|
public static final void startMigrateAll(String path) throws Exception {
|
||||||
MigrationTool.ui.println("Project Migration");
|
MigrationTool.ui.println("Project Migration");
|
||||||
MigrationTool.ui.println("Copyright (c) 2006, Intel Corporation");
|
MigrationTool.ui.println("Copyright (c) 2006, Intel Corporation");
|
||||||
Common.toDoAll(path, MigrationTool.class.getMethod("seekModule", String.class), null, null, Common.DIR);
|
Common.toDoAll(path, MigrationTool.class.getMethod("seekModule", String.class), null, null, Common.DIR);
|
||||||
|
|
Loading…
Reference in New Issue