]> git.proxmox.com Git - mirror_edk2.git/commitdiff
func name changed & modify common.todoall
authoralfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 31 Aug 2006 01:06:09 +0000 (01:06 +0000)
committeralfred <alfred@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 31 Aug 2006 01:06:09 +0000 (01:06 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1412 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/MigrationTools/org/tianocore/migration/Common.java
Tools/Source/MigrationTools/org/tianocore/migration/FirstPanel.java
Tools/Source/MigrationTools/org/tianocore/migration/MigrationTool.java

index 44b25e7e12d9b630c367c13a1c185b8855da05ca..5b4d33adb8299e8fa0633a90d5b1250a3d5a2503 100644 (file)
@@ -60,7 +60,13 @@ public final class Common {
        //-----------------------------------file&string---------------------------------------//\r
 \r
        //--------------------------------------dir--------------------------------------------//\r
-       \r
+       /*\r
+       public static final HashSet<String> walkDir(String path, int mode) throws Exception {\r
+               HashSet<String> pathlist = new HashSet<String>();\r
+               Common.toDoAll(path, Common.class.getMethod("walkDir", String.class), null, null, mode);\r
+               return pathlist;\r
+       }\r
+       */\r
        public static final void ensureDir(String objFileWhole) {\r
                File tempdir;\r
                Matcher mtrseparate = ptnseparate.matcher(objFileWhole);\r
@@ -137,16 +143,21 @@ public final class Common {
                }\r
        }\r
        \r
-       public static void toDoAll(String path, ForDoAll fda) throws Exception { // filter of file type can be done in toDo\r
+       public static void toDoAll(String path, ForDoAll fda, int type) throws Exception { // filter of file type can be done in toDo\r
                String[] list = new File(path).list();\r
                File test;\r
 \r
+               if (type == DIR || type == BOTH) {\r
+                       fda.toDo(path);\r
+               }\r
                for (int i = 0 ; i < list.length ; i++) {\r
                        test = new File(path + File.separator + list[i]);\r
                        if (test.isDirectory()) {\r
-                               toDoAll(path + File.separator + list[i], fda);\r
+                               toDoAll(path + File.separator + list[i], fda, type);\r
                        } else {\r
-                               fda.toDo(path + File.separator + list[i]);\r
+                               if (type == FILE || type == BOTH) {\r
+                                       fda.toDo(path + File.separator + list[i]);\r
+                               }\r
                        }\r
                }\r
        }\r
@@ -154,4 +165,42 @@ public final class Common {
        public static interface ForDoAll {\r
                public void toDo(String filepath) throws Exception;\r
        }\r
+       /*\r
+       // this PathIterator is based on HashSet, an thread implementation is required.\r
+       private final class PathIterator implements ForDoAll{\r
+               PathIterator(String path) throws Exception {\r
+                       startpath = path;\r
+                       Common.toDoAll(startpath, this, mode);\r
+               }\r
+               PathIterator(String path, int md) throws Exception {\r
+                       startpath = path;\r
+                       mode = md;\r
+                       Common.toDoAll(startpath, this, mode);\r
+               }\r
+               private String startpath;\r
+               private int mode = Common.BOTH;\r
+               private HashSet<String> pathlist = new HashSet<String>();\r
+               private Iterator<String> it = pathlist.iterator();\r
+               \r
+               public final void toDo(String path) throws Exception {\r
+                       pathlist.add(path);\r
+               }\r
+               \r
+               public final String next() {\r
+                       return it.next();\r
+               }\r
+               \r
+               public final boolean hasNext() {\r
+                       return it.hasNext();\r
+               }\r
+               \r
+               public final String toString() {\r
+                       return pathlist.toString();\r
+               }\r
+       }\r
+       \r
+       public final PathIterator getPathIterator(String path, int md) throws Exception {\r
+               return new PathIterator(path, md);\r
+       }\r
+       */\r
 }\r
index fac874e381fd9a95c0895b1a585b111299c37556..ce15570807525a38eab17f40478ed2d2c84f73a9 100644 (file)
@@ -184,7 +184,7 @@ public final class FirstPanel extends JPanel implements ActionListener, ItemList
         if ( e.getSource() == goButton ) {\r
                try {\r
                        logfile = new PrintWriter(new BufferedWriter(new FileWriter(startpath.replaceAll(Common.strseparate, "$1") + File.separator + "migration.log")));\r
-                       MigrationTool.triger(startpath);\r
+                       MigrationTool.startMigrateAll(startpath);\r
                        logfile.flush();\r
                } catch (Exception en) {\r
                        println(en.getMessage());\r
index 04ab0221b98f0ecc03134dfc5294d744fad43fb2..5c74ee03f18724d6fea8a7a83b47031c06d0112b 100644 (file)
@@ -13,7 +13,7 @@ public class MigrationTool {
        public static boolean doCritic = false;\r
        public static boolean defaultoutput = false;\r
 \r
-       private static final void manipulate(ModuleInfo mi) throws Exception {\r
+       private static final void mainFlow(ModuleInfo mi) throws Exception {\r
 \r
                ModuleReader.ModuleScan(mi);\r
                //MigrationTool.ui.yesOrNo("go on replace?");\r
@@ -59,11 +59,11 @@ public class MigrationTool {
 \r
        public static final void seekModule(String filepath) throws Exception {\r
                if (ModuleInfo.isModule(filepath)) {\r
-                       manipulate(new ModuleInfo(filepath));\r
+                       mainFlow(new ModuleInfo(filepath));\r
                }\r
        }\r
 \r
-       public static final void triger(String path) throws Exception {\r
+       public static final void startMigrateAll(String path) throws Exception {\r
                MigrationTool.ui.println("Project Migration");\r
                MigrationTool.ui.println("Copyright (c) 2006, Intel Corporation");\r
                Common.toDoAll(path, MigrationTool.class.getMethod("seekModule", String.class), null, null, Common.DIR);\r