]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/common/FileOperation.java
1. Restructure some folders and files
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / common / FileOperation.java
index 21d6cfa596543e3358ee6ce8d0da4aa8b570ce51..b0802a60e81d43696596bb02e46076412f7f2754 100644 (file)
@@ -28,7 +28,7 @@ public class FileOperation {
      \r
      **/\r
     public static void main(String[] args) throws Exception {\r
-        FileOperation.newFolder("C:\\aaa\\bbb\\ccc\\ddd\\eee");\r
+        FileOperation.newFolder("C:\\aaa\\aaa\\aaa\\aaa\\aaa");\r
     }\r
 \r
     /**\r
@@ -45,14 +45,14 @@ public class FileOperation {
             if (folderPath.indexOf(DataType.FILE_SEPARATOR) > -1) {\r
                 temp = temp + folderPath.substring(0, folderPath.indexOf(DataType.FILE_SEPARATOR));\r
                 if (temp.endsWith(":")) {\r
-                    temp = temp + DataType.FILE_SEPARATOR;\r
+                    temp = Tools.addFileSeparator(temp);\r
                     folderPath = folderPath.substring(folderPath.indexOf(DataType.FILE_SEPARATOR) + DataType.FILE_SEPARATOR.length());\r
                     continue;\r
                 }\r
-                temp = temp + DataType.FILE_SEPARATOR;\r
+                temp = Tools.addFileSeparator(temp);\r
                 folderPath = folderPath.substring(folderPath.indexOf(DataType.FILE_SEPARATOR) + DataType.FILE_SEPARATOR.length());    \r
             } else {\r
-                temp = temp + DataType.FILE_SEPARATOR + folderPath;\r
+                temp = Tools.addFileSeparator(temp) + folderPath;\r
                 folderPath = "";\r
             }\r
             File f = new File(temp);\r
@@ -140,8 +140,16 @@ public class FileOperation {
      \r
      **/\r
     public static void copyFile(String oldPath, String newPath) throws Exception {\r
+        oldPath = Tools.convertPathToCurrentOsType(oldPath);\r
+        newPath = Tools.convertPathToCurrentOsType(newPath);\r
+        \r
         int byteCount = 0;\r
         File oldFile = new File(oldPath);\r
+        \r
+        File newFile = new File(Tools.getFilePathOnly(newPath));\r
+        if (!newFile.exists()) {\r
+            newFolder(Tools.getFilePathOnly(newPath));\r
+        }\r
 \r
         if (oldFile.exists()) {\r
             InputStream is = new FileInputStream(oldPath);\r