+/** @file\r
+ \r
+ Copyright (c) 2006, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+ \r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ \r
+ **/\r
package org.tianocore.migration;\r
\r
import java.io.*;\r
import java.util.*;\r
\r
public class Common {\r
+ public static Pattern ptnseparate = Pattern.compile("(.*)\\\\([^\\\\]*)");\r
+ \r
public static String file2string(String filename) throws Exception {\r
BufferedReader rd = new BufferedReader(new FileReader(filename));\r
StringBuffer wholefile = new StringBuffer();\r
}\r
\r
public static void ensureDir(String objFileWhole) {\r
- Pattern ptnseparate = Pattern.compile("(.*)\\\\[^\\\\]*");\r
- Matcher mtrseparate;\r
File tempdir;\r
-\r
- mtrseparate = ptnseparate.matcher(objFileWhole);\r
+ Matcher mtrseparate = ptnseparate.matcher(objFileWhole);\r
if (mtrseparate.find()) {\r
tempdir = new File(mtrseparate.group(1));\r
if (!tempdir.exists()) tempdir.mkdirs();\r
\r
return filelist;\r
}\r
+\r
+ public static String dirCopy_(String src) throws Exception {\r
+ Matcher mtrseparate = Common.ptnseparate.matcher(src);\r
+ if (mtrseparate.find()) {\r
+ dirCopy(src, mtrseparate.group(1) + File.separator + "_" + mtrseparate.group(2));\r
+ }\r
+ return mtrseparate.group(1) + File.separator + "_" + mtrseparate.group(2);\r
+ }\r
+ \r
+ public static void dirCopy(String src, String des) throws Exception {\r
+ String[] list = new File(src).list();\r
+ File test;\r
+\r
+ for (int i = 0 ; i < list.length ; i++) {\r
+ test = new File(src + File.separator + list[i]);\r
+ if (test.isDirectory()) {\r
+ dirCopy(src + File.separator + list[i], des + File.separator + list[i]);\r
+ } else {\r
+ ensureDir(des + File.separator + list[i]);\r
+ string2file(file2string(src + File.separator + list[i]), des + File.separator + list[i]);\r
+ }\r
+ }\r
+ }\r
\r
public static void toDoAll(String path, ForDoAll fda) throws Exception { // filter of file type can be done in toDo\r
String[] list = new File(path).list();\r