diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/command')
3 files changed, 12 insertions, 5 deletions
diff --git a/src/main/java/cuchaz/enigma/command/Command.java b/src/main/java/cuchaz/enigma/command/Command.java index d53ed6e..09dd321 100644 --- a/src/main/java/cuchaz/enigma/command/Command.java +++ b/src/main/java/cuchaz/enigma/command/Command.java | |||
| @@ -13,6 +13,8 @@ import java.nio.file.Files; | |||
| 13 | import java.nio.file.Path; | 13 | import java.nio.file.Path; |
| 14 | import java.nio.file.Paths; | 14 | import java.nio.file.Paths; |
| 15 | 15 | ||
| 16 | import com.google.common.io.MoreFiles; | ||
| 17 | |||
| 16 | public abstract class Command { | 18 | public abstract class Command { |
| 17 | public final String name; | 19 | public final String name; |
| 18 | 20 | ||
| @@ -49,6 +51,8 @@ public abstract class Command { | |||
| 49 | protected static MappingFormat chooseEnigmaFormat(Path path) { | 51 | protected static MappingFormat chooseEnigmaFormat(Path path) { |
| 50 | if (Files.isDirectory(path)) { | 52 | if (Files.isDirectory(path)) { |
| 51 | return MappingFormat.ENIGMA_DIRECTORY; | 53 | return MappingFormat.ENIGMA_DIRECTORY; |
| 54 | } else if ("zip".equalsIgnoreCase(MoreFiles.getFileExtension(path))) { | ||
| 55 | return MappingFormat.ENIGMA_ZIP; | ||
| 52 | } else { | 56 | } else { |
| 53 | return MappingFormat.ENIGMA_FILE; | 57 | return MappingFormat.ENIGMA_FILE; |
| 54 | } | 58 | } |
diff --git a/src/main/java/cuchaz/enigma/command/MapSpecializedMethodsCommand.java b/src/main/java/cuchaz/enigma/command/MapSpecializedMethodsCommand.java index 7696f0f..eb8d5dc 100644 --- a/src/main/java/cuchaz/enigma/command/MapSpecializedMethodsCommand.java +++ b/src/main/java/cuchaz/enigma/command/MapSpecializedMethodsCommand.java | |||
| @@ -36,10 +36,13 @@ public class MapSpecializedMethodsCommand extends Command { | |||
| 36 | 36 | ||
| 37 | @Override | 37 | @Override |
| 38 | public void run(String... args) throws IOException, MappingParseException { | 38 | public void run(String... args) throws IOException, MappingParseException { |
| 39 | run(Paths.get(args[0]), args[1], Paths.get(args[2]), args[3], Paths.get(args[4])); | ||
| 40 | } | ||
| 41 | |||
| 42 | public static void run(Path jar, String sourceFormat, Path sourcePath, String resultFormat, Path output) throws IOException, MappingParseException { | ||
| 39 | MappingSaveParameters saveParameters = new MappingSaveParameters(MappingFileNameFormat.BY_DEOBF); | 43 | MappingSaveParameters saveParameters = new MappingSaveParameters(MappingFileNameFormat.BY_DEOBF); |
| 40 | EntryTree<EntryMapping> source = MappingCommandsUtil.read(args[1], Paths.get(args[2]), saveParameters); | 44 | EntryTree<EntryMapping> source = MappingCommandsUtil.read(sourceFormat, sourcePath, saveParameters); |
| 41 | EntryTree<EntryMapping> result = new HashEntryTree<>(); | 45 | EntryTree<EntryMapping> result = new HashEntryTree<>(); |
| 42 | Path jar = Paths.get(args[0]); | ||
| 43 | ClassCache classCache = ClassCache.of(jar); | 46 | ClassCache classCache = ClassCache.of(jar); |
| 44 | JarIndex jarIndex = classCache.index(ProgressListener.none()); | 47 | JarIndex jarIndex = classCache.index(ProgressListener.none()); |
| 45 | BridgeMethodIndex bridgeMethodIndex = jarIndex.getBridgeMethodIndex(); | 48 | BridgeMethodIndex bridgeMethodIndex = jarIndex.getBridgeMethodIndex(); |
| @@ -60,8 +63,7 @@ public class MapSpecializedMethodsCommand extends Command { | |||
| 60 | result.insert(specialized, new EntryMapping(name)); | 63 | result.insert(specialized, new EntryMapping(name)); |
| 61 | } | 64 | } |
| 62 | 65 | ||
| 63 | Path output = Paths.get(args[4]); | ||
| 64 | Utils.delete(output); | 66 | Utils.delete(output); |
| 65 | MappingCommandsUtil.write(result, args[3], output, saveParameters); | 67 | MappingCommandsUtil.write(result, resultFormat, output, saveParameters); |
| 66 | } | 68 | } |
| 67 | } | 69 | } |
diff --git a/src/main/java/cuchaz/enigma/command/MappingCommandsUtil.java b/src/main/java/cuchaz/enigma/command/MappingCommandsUtil.java index fc68edf..fc7afbc 100644 --- a/src/main/java/cuchaz/enigma/command/MappingCommandsUtil.java +++ b/src/main/java/cuchaz/enigma/command/MappingCommandsUtil.java | |||
| @@ -17,6 +17,7 @@ import cuchaz.enigma.translation.representation.entry.FieldEntry; | |||
| 17 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | 17 | import cuchaz.enigma.translation.representation.entry.MethodEntry; |
| 18 | 18 | ||
| 19 | import java.io.IOException; | 19 | import java.io.IOException; |
| 20 | import java.nio.file.Files; | ||
| 20 | import java.nio.file.Path; | 21 | import java.nio.file.Path; |
| 21 | import java.util.HashSet; | 22 | import java.util.HashSet; |
| 22 | import java.util.Set; | 23 | import java.util.Set; |
| @@ -81,7 +82,7 @@ public final class MappingCommandsUtil { | |||
| 81 | 82 | ||
| 82 | public static EntryTree<EntryMapping> read(String type, Path path, MappingSaveParameters saveParameters) throws MappingParseException, IOException { | 83 | public static EntryTree<EntryMapping> read(String type, Path path, MappingSaveParameters saveParameters) throws MappingParseException, IOException { |
| 83 | if (type.equals("enigma")) { | 84 | if (type.equals("enigma")) { |
| 84 | return EnigmaMappingsReader.DIRECTORY.read(path, ProgressListener.none(), saveParameters); | 85 | return (Files.isDirectory(path) ? EnigmaMappingsReader.DIRECTORY : EnigmaMappingsReader.ZIP).read(path, ProgressListener.none(), saveParameters); |
| 85 | } | 86 | } |
| 86 | 87 | ||
| 87 | if (type.equals("tiny")) { | 88 | if (type.equals("tiny")) { |