diff options
| author | 2016-08-24 01:59:26 +0200 | |
|---|---|---|
| committer | 2016-08-24 01:59:26 +0200 | |
| commit | 6e9934a442394a9d0a81404c7480b8001939d92b (patch) | |
| tree | 28252cd87aae33ccc2da9f7c83dcf63db2f45578 /src/main/java/cuchaz/enigma/mapping | |
| parent | Revert Main.java (diff) | |
| download | enigma-fork-6e9934a442394a9d0a81404c7480b8001939d92b.tar.gz enigma-fork-6e9934a442394a9d0a81404c7480b8001939d92b.tar.xz enigma-fork-6e9934a442394a9d0a81404c7480b8001939d92b.zip | |
Add mapping converter to command line system
Diffstat (limited to 'src/main/java/cuchaz/enigma/mapping')
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/Mappings.java | 12 | ||||
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/MappingsSRGWriter.java | 9 |
2 files changed, 17 insertions, 4 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/Mappings.java b/src/main/java/cuchaz/enigma/mapping/Mappings.java index 171ddf1..47c4232 100644 --- a/src/main/java/cuchaz/enigma/mapping/Mappings.java +++ b/src/main/java/cuchaz/enigma/mapping/Mappings.java | |||
| @@ -13,6 +13,8 @@ package cuchaz.enigma.mapping; | |||
| 13 | import com.google.common.collect.Lists; | 13 | import com.google.common.collect.Lists; |
| 14 | import com.google.common.collect.Maps; | 14 | import com.google.common.collect.Maps; |
| 15 | 15 | ||
| 16 | import java.io.File; | ||
| 17 | import java.io.IOException; | ||
| 16 | import java.util.ArrayList; | 18 | import java.util.ArrayList; |
| 17 | import java.util.Collection; | 19 | import java.util.Collection; |
| 18 | import java.util.List; | 20 | import java.util.List; |
| @@ -202,6 +204,16 @@ public class Mappings { | |||
| 202 | return originMapping; | 204 | return originMapping; |
| 203 | } | 205 | } |
| 204 | 206 | ||
| 207 | public void saveEnigmaMappings(File file, boolean isDirectoryFormat) throws IOException | ||
| 208 | { | ||
| 209 | new MappingsEnigmaWriter().write(file, this, isDirectoryFormat); | ||
| 210 | } | ||
| 211 | |||
| 212 | public void saveSRGMappings(File file) throws IOException | ||
| 213 | { | ||
| 214 | new MappingsSRGWriter().write(file, this); | ||
| 215 | } | ||
| 216 | |||
| 205 | public enum FormatType | 217 | public enum FormatType |
| 206 | { | 218 | { |
| 207 | ENIGMA_FILE, ENIGMA_DIRECTORY, SRG_FILE | 219 | ENIGMA_FILE, ENIGMA_DIRECTORY, SRG_FILE |
diff --git a/src/main/java/cuchaz/enigma/mapping/MappingsSRGWriter.java b/src/main/java/cuchaz/enigma/mapping/MappingsSRGWriter.java index a05b915..cede1c2 100644 --- a/src/main/java/cuchaz/enigma/mapping/MappingsSRGWriter.java +++ b/src/main/java/cuchaz/enigma/mapping/MappingsSRGWriter.java | |||
| @@ -2,6 +2,7 @@ package cuchaz.enigma.mapping; | |||
| 2 | 2 | ||
| 3 | import com.google.common.base.Charsets; | 3 | import com.google.common.base.Charsets; |
| 4 | import cuchaz.enigma.Deobfuscator; | 4 | import cuchaz.enigma.Deobfuscator; |
| 5 | import cuchaz.enigma.analysis.TranslationIndex; | ||
| 5 | 6 | ||
| 6 | import java.io.*; | 7 | import java.io.*; |
| 7 | import java.util.ArrayList; | 8 | import java.util.ArrayList; |
| @@ -13,13 +14,13 @@ import java.util.List; | |||
| 13 | */ | 14 | */ |
| 14 | public class MappingsSRGWriter { | 15 | public class MappingsSRGWriter { |
| 15 | 16 | ||
| 16 | public void write(File file, Deobfuscator deobfuscator) throws IOException { | 17 | public void write(File file, Mappings mappings) throws IOException { |
| 17 | if(file.exists()){ | 18 | if(file.exists()){ |
| 18 | file.delete(); | 19 | file.delete(); |
| 19 | } | 20 | } |
| 20 | file.createNewFile(); | 21 | file.createNewFile(); |
| 21 | 22 | ||
| 22 | Mappings mappings = deobfuscator.getMappings(); | 23 | TranslationIndex index = new TranslationIndex(); |
| 23 | 24 | ||
| 24 | PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8)); | 25 | PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8)); |
| 25 | List<String> fieldMappings = new ArrayList<>(); | 26 | List<String> fieldMappings = new ArrayList<>(); |
| @@ -43,7 +44,7 @@ public class MappingsSRGWriter { | |||
| 43 | } | 44 | } |
| 44 | 45 | ||
| 45 | for (MethodMapping methodMapping : sorted(innerClassMapping.methods())) { | 46 | for (MethodMapping methodMapping : sorted(innerClassMapping.methods())) { |
| 46 | methodMappings.add("MD: " + innerClassName + "/" + methodMapping.getObfName() + " " + methodMapping.getObfSignature().toString().replace("none/", "") + " " + innerDebofClassName + "/" + methodMapping.getDeobfName() + " " + deobfuscator.getTranslator(TranslationDirection.Deobfuscating).translateSignature(methodMapping.getObfSignature())); | 47 | methodMappings.add("MD: " + innerClassName + "/" + methodMapping.getObfName() + " " + methodMapping.getObfSignature().toString().replace("none/", "") + " " + innerDebofClassName + "/" + methodMapping.getDeobfName() + " " + mappings.getTranslator(TranslationDirection.Deobfuscating, index).translateSignature(methodMapping.getObfSignature())); |
| 47 | } | 48 | } |
| 48 | } | 49 | } |
| 49 | 50 | ||
| @@ -52,7 +53,7 @@ public class MappingsSRGWriter { | |||
| 52 | } | 53 | } |
| 53 | 54 | ||
| 54 | for (MethodMapping methodMapping : sorted(classMapping.methods())) { | 55 | for (MethodMapping methodMapping : sorted(classMapping.methods())) { |
| 55 | methodMappings.add("MD: " + classMapping.getObfFullName().replace("none/", "") + "/" + methodMapping.getObfName() + " " + methodMapping.getObfSignature().toString().replace("none/", "") + " " + classMapping.getDeobfName() + "/" + methodMapping.getDeobfName() + " " + deobfuscator.getTranslator(TranslationDirection.Deobfuscating).translateSignature(methodMapping.getObfSignature())); | 56 | methodMappings.add("MD: " + classMapping.getObfFullName().replace("none/", "") + "/" + methodMapping.getObfName() + " " + methodMapping.getObfSignature().toString().replace("none/", "") + " " + classMapping.getDeobfName() + "/" + methodMapping.getDeobfName() + " " + mappings.getTranslator(TranslationDirection.Deobfuscating, index).translateSignature(methodMapping.getObfSignature())); |
| 56 | } | 57 | } |
| 57 | } | 58 | } |
| 58 | for(String fd : fieldMappings){ | 59 | for(String fd : fieldMappings){ |