]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/MigrationTools/org/tianocore/migration/SourceFileReplacer.java
Many Many Modifies
[mirror_edk2.git] / Tools / Source / MigrationTools / org / tianocore / migration / SourceFileReplacer.java
index d213693c24a7dc7b6a3e4678e0c2270d4e759bc7..c1c36981d5d8ac78f86e1cadade3fa99e97d5937 100644 (file)
@@ -17,14 +17,16 @@ import java.util.*;
 import java.util.regex.Matcher;\r
 import java.util.regex.Pattern;\r
 \r
-public class SourceFileReplacer {\r
-       SourceFileReplacer(String path, ModuleInfo moduleinfo, Database database, UI fp) {\r
+public final class SourceFileReplacer {\r
+       SourceFileReplacer(String path, String outpath, ModuleInfo moduleinfo, Database database, UI fp) {\r
                modulepath = path;\r
+               outputpath = outpath;\r
                mi = moduleinfo;\r
                db = database;\r
                ui = fp;\r
        }\r
        private String modulepath;\r
+       private String outputpath;\r
        private ModuleInfo mi;\r
        private Database db;\r
        private UI ui;\r
@@ -47,7 +49,7 @@ public class SourceFileReplacer {
        private Set<r8tor9> fileprotocol = new HashSet<r8tor9>();\r
        private Set<String> filer8only = new HashSet<String>();\r
        \r
-       private String r8only = "EfiLibInstallDriverBinding " +\r
+       private static final String r8only = "EfiLibInstallDriverBinding " +\r
                        "EfiLibInstallAllDriverProtocols " +\r
                        "EfiLibCompareLanguage " +\r
                        "BufToHexString " +\r
@@ -68,7 +70,6 @@ public class SourceFileReplacer {
                        "GetIoPortSpaceAddressHobInfo ";\r
        \r
        public void flush() throws Exception {\r
-               PrintWriter outfile;\r
                String outname = null;\r
                String inname = null;\r
                if (ui.yesOrNo("Changes will be made to the Source Code.  View details?")) {\r
@@ -85,14 +86,7 @@ public class SourceFileReplacer {
                                        outname = inname;\r
                                }\r
                                ui.println("\nModifying file: " + inname);\r
-                               Common.string2file(sourcefilereplace(modulepath + File.separator + "temp" + File.separator + inname), modulepath + File.separator + "result" + File.separator + outname);\r
-                               /*\r
-                               Common.ensureDir(modulepath + File.separator + "result" + File.separator + outname);\r
-                               outfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + outname)));\r
-                               outfile.append(sourcefilereplace(modulepath + File.separator + "temp" + File.separator + inname));\r
-                               outfile.flush();\r
-                               outfile.close();\r
-                               */\r
+                               Common.string2file(sourcefilereplace(modulepath + File.separator + "temp" + File.separator + inname), outputpath + File.separator + "Migration_" + mi.modulename + File.separator + outname);\r
                        } else if (inname.contains(".h") || inname.contains(".H") || inname.contains(".dxs") || inname.contains(".uni")) {\r
                                if (inname.contains(".H")) {\r
                                        outname = inname.replaceFirst(".H", ".h");\r
@@ -100,14 +94,7 @@ public class SourceFileReplacer {
                                        outname = inname;\r
                                }\r
                                ui.println("\nCopying file: " + inname);\r
-                               Common.string2file(Common.file2string(modulepath + File.separator + "temp" + File.separator + inname), modulepath + File.separator + "result" + File.separator + outname);\r
-                               /*\r
-                               Common.ensureDir(modulepath + File.separator + "result" + File.separator + outname);\r
-                               outfile = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + outname)));\r
-                               outfile.append(Common.file2string(modulepath + File.separator + "temp" + File.separator + inname));\r
-                               outfile.flush();\r
-                               outfile.close();\r
-                               */\r
+                               Common.string2file(Common.file2string(modulepath + File.separator + "temp" + File.separator + inname), outputpath + File.separator + "Migration_" + mi.modulename + File.separator + outname);\r
                        }\r
                }\r
 \r
@@ -120,8 +107,8 @@ public class SourceFileReplacer {
                String paragraph = null;\r
                String line = Common.file2string(Database.defaultpath + File.separator + "R8Lib.c");\r
                Common.ensureDir(modulepath + File.separator + "result" + File.separator + "R8Lib.c");\r
-               PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + "R8Lib.c")));\r
-               PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(modulepath + File.separator + "result" + File.separator + "R8Lib.h")));\r
+               PrintWriter outfile1 = new PrintWriter(new BufferedWriter(new FileWriter(outputpath + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.c")));\r
+               PrintWriter outfile2 = new PrintWriter(new BufferedWriter(new FileWriter(outputpath + File.separator + "Migration_" + mi.modulename + File.separator + "R8Lib.h")));\r
                Pattern ptnr8only = Pattern.compile("////#?(\\w*)?.*?R8_(\\w*).*?////~", Pattern.DOTALL);\r
                Matcher mtrr8only = ptnr8only.matcher(line);\r
                Matcher mtrr8onlyhead;\r