//-----------------------------------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
}\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
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
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
\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