Turn to Regex in ModuleReader.java
[mirror_edk2.git] / Tools / Source / MigrationTools / org / tianocore / migration / SourceFileReplacer.java
index dbe981ef94adccedf98431c51986348b2b1c969f..03617ab7167cc61e51d0031b20be09fced2b994a 100644 (file)
@@ -85,7 +85,7 @@ public class SourceFileReplacer {
                                        outname = inname;\r
                                }\r
                                ui.println("\nModifying file: " + inname);\r
-                               mi.ensureDir(modulepath + File.separator + "result" + File.separator + outname);\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
@@ -97,9 +97,9 @@ public class SourceFileReplacer {
                                        outname = inname;\r
                                }\r
                                ui.println("\nCopying file: " + inname);\r
-                               mi.ensureDir(modulepath + File.separator + "result" + File.separator + outname);\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(sourcefiletostring(modulepath + File.separator + "temp" + File.separator + inname));\r
+                               outfile.append(Common.sourcefiletostring(modulepath + File.separator + "temp" + File.separator + inname));\r
                                outfile.flush();\r
                                outfile.close();\r
                        }\r
@@ -112,8 +112,8 @@ public class SourceFileReplacer {
        \r
        private void addr8only() throws Exception {\r
                String paragraph = null;\r
-               String line = sourcefiletostring(Database.defaultpath + File.separator + "R8Lib.c");\r
-               mi.ensureDir(modulepath + File.separator + "result" + File.separator + "R8Lib.c");\r
+               String line = Common.sourcefiletostring(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
                Pattern ptnr8only = Pattern.compile("////#?(\\w*)?.*?R8_(\\w*).*?////~", Pattern.DOTALL);\r
@@ -142,16 +142,6 @@ public class SourceFileReplacer {
                mi.localmodulesources.add("R8Lib.c");\r
        }\r
        \r
-       private String sourcefiletostring(String filename) throws Exception {\r
-               BufferedReader rd = new BufferedReader(new FileReader(filename));\r
-               StringBuffer wholefile = new StringBuffer();\r
-               String line;\r
-               while ((line = rd.readLine()) != null) {\r
-                       wholefile.append(line + "\n");\r
-               }\r
-               return wholefile.toString();\r
-       }\r
-       \r
        // Caution : if there is @ in file , it will be replaced with \n , so is you use Doxygen ... God Bless you!\r
        private String sourcefilereplace(String filename) throws Exception {\r
                BufferedReader rd = new BufferedReader(new FileReader(filename));\r