From: alfred Date: Thu, 31 Aug 2006 01:06:09 +0000 (+0000) Subject: func name changed & modify common.todoall X-Git-Tag: edk2-stable201903~24462 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=b678aacaa9876e8a1f14c4e9e93df87d3d4977b2 func name changed & modify common.todoall git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1412 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/Common.java b/Tools/Source/MigrationTools/org/tianocore/migration/Common.java index 44b25e7e12..5b4d33adb8 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/Common.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/Common.java @@ -60,7 +60,13 @@ public final class Common { //-----------------------------------file&string---------------------------------------// //--------------------------------------dir--------------------------------------------// - + /* + public static final HashSet walkDir(String path, int mode) throws Exception { + HashSet pathlist = new HashSet(); + Common.toDoAll(path, Common.class.getMethod("walkDir", String.class), null, null, mode); + return pathlist; + } + */ public static final void ensureDir(String objFileWhole) { File tempdir; Matcher mtrseparate = ptnseparate.matcher(objFileWhole); @@ -137,16 +143,21 @@ 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(); File test; + if (type == DIR || type == BOTH) { + fda.toDo(path); + } for (int i = 0 ; i < list.length ; i++) { test = new File(path + File.separator + list[i]); if (test.isDirectory()) { - toDoAll(path + File.separator + list[i], fda); + toDoAll(path + File.separator + list[i], fda, type); } else { - fda.toDo(path + File.separator + list[i]); + if (type == FILE || type == BOTH) { + fda.toDo(path + File.separator + list[i]); + } } } } @@ -154,4 +165,42 @@ public final class Common { public static interface ForDoAll { 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 pathlist = new HashSet(); + private Iterator 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); + } + */ } diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java b/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java index fac874e381..ce15570807 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java @@ -184,7 +184,7 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList if ( e.getSource() == goButton ) { try { logfile = new PrintWriter(new BufferedWriter(new FileWriter(startpath.replaceAll(Common.strseparate, "$1") + File.separator + "migration.log"))); - MigrationTool.triger(startpath); + MigrationTool.startMigrateAll(startpath); logfile.flush(); } catch (Exception en) { println(en.getMessage()); diff --git a/Tools/Source/MigrationTools/org/tianocore/migration/MigrationTool.java b/Tools/Source/MigrationTools/org/tianocore/migration/MigrationTool.java index 04ab0221b9..5c74ee03f1 100644 --- a/Tools/Source/MigrationTools/org/tianocore/migration/MigrationTool.java +++ b/Tools/Source/MigrationTools/org/tianocore/migration/MigrationTool.java @@ -13,7 +13,7 @@ public class MigrationTool { public static boolean doCritic = 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); //MigrationTool.ui.yesOrNo("go on replace?"); @@ -59,11 +59,11 @@ public class MigrationTool { public static final void seekModule(String filepath) throws Exception { 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("Copyright (c) 2006, Intel Corporation"); Common.toDoAll(path, MigrationTool.class.getMethod("seekModule", String.class), null, null, Common.DIR);