diff options
| author | 2016-08-12 19:59:54 +0200 | |
|---|---|---|
| committer | 2016-08-12 19:59:54 +0200 | |
| commit | 6032f55ede3c1b550cfd83b2f768926c992d9a98 (patch) | |
| tree | 75aa7866c2dd635d03798819ea0e691ec85f2247 | |
| parent | Implement Enigma directory format (#1) (diff) | |
| download | enigma-6032f55ede3c1b550cfd83b2f768926c992d9a98.tar.gz enigma-6032f55ede3c1b550cfd83b2f768926c992d9a98.tar.xz enigma-6032f55ede3c1b550cfd83b2f768926c992d9a98.zip | |
Remoe JSON directory format support and clean up others things
16 files changed, 32 insertions, 465 deletions
diff --git a/src/main/java/cuchaz/enigma/CommandMain.java b/src/main/java/cuchaz/enigma/CommandMain.java index 4e3f4479..06784584 100644 --- a/src/main/java/cuchaz/enigma/CommandMain.java +++ b/src/main/java/cuchaz/enigma/CommandMain.java | |||
| @@ -15,7 +15,7 @@ import java.util.jar.JarFile; | |||
| 15 | 15 | ||
| 16 | import cuchaz.enigma.Deobfuscator.ProgressListener; | 16 | import cuchaz.enigma.Deobfuscator.ProgressListener; |
| 17 | import cuchaz.enigma.mapping.Mappings; | 17 | import cuchaz.enigma.mapping.Mappings; |
| 18 | import cuchaz.enigma.mapping.MappingsJsonReader; | 18 | import cuchaz.enigma.mapping.MappingsEnigmaReader; |
| 19 | 19 | ||
| 20 | public class CommandMain { | 20 | public class CommandMain { |
| 21 | 21 | ||
| @@ -47,7 +47,7 @@ public class CommandMain { | |||
| 47 | this.lastReportTime = now; | 47 | this.lastReportTime = now; |
| 48 | } | 48 | } |
| 49 | if (isLastUpdate) { | 49 | if (isLastUpdate) { |
| 50 | double elapsedSeconds = (now - this.startTime) / 1000; | 50 | double elapsedSeconds = (now - this.startTime) / 1000.0; |
| 51 | System.out.println(String.format("Finished in %.1f seconds", elapsedSeconds)); | 51 | System.out.println(String.format("Finished in %.1f seconds", elapsedSeconds)); |
| 52 | } | 52 | } |
| 53 | } | 53 | } |
| @@ -119,7 +119,7 @@ public class CommandMain { | |||
| 119 | Deobfuscator deobfuscator = new Deobfuscator(jar); | 119 | Deobfuscator deobfuscator = new Deobfuscator(jar); |
| 120 | if (fileMappings != null) { | 120 | if (fileMappings != null) { |
| 121 | System.out.println("Reading mappings..."); | 121 | System.out.println("Reading mappings..."); |
| 122 | Mappings mappings = new MappingsJsonReader().read(fileMappings); | 122 | Mappings mappings = new MappingsEnigmaReader().read(fileMappings); |
| 123 | deobfuscator.setMappings(mappings); | 123 | deobfuscator.setMappings(mappings); |
| 124 | } | 124 | } |
| 125 | return deobfuscator; | 125 | return deobfuscator; |
| @@ -143,7 +143,7 @@ public class CommandMain { | |||
| 143 | File file = new File(path).getAbsoluteFile(); | 143 | File file = new File(path).getAbsoluteFile(); |
| 144 | File dir = file.getParentFile(); | 144 | File dir = file.getParentFile(); |
| 145 | if (dir == null) { | 145 | if (dir == null) { |
| 146 | throw new IllegalArgumentException("Cannot write to folder: " + dir); | 146 | throw new IllegalArgumentException("Cannot write file: " + path); |
| 147 | } | 147 | } |
| 148 | // quick fix to avoid stupid stuff in Gradle code | 148 | // quick fix to avoid stupid stuff in Gradle code |
| 149 | if (!dir.isDirectory()) { | 149 | if (!dir.isDirectory()) { |
diff --git a/src/main/java/cuchaz/enigma/Main.java b/src/main/java/cuchaz/enigma/Main.java index 0be1d90c..c1419823 100644 --- a/src/main/java/cuchaz/enigma/Main.java +++ b/src/main/java/cuchaz/enigma/Main.java | |||
| @@ -28,7 +28,7 @@ public class Main { | |||
| 28 | gui.getController().openJar(new JarFile(getFile(args[0]))); | 28 | gui.getController().openJar(new JarFile(getFile(args[0]))); |
| 29 | } | 29 | } |
| 30 | if (args.length >= 2) { | 30 | if (args.length >= 2) { |
| 31 | gui.getController().openJsonMappings(getFile(args[1])); | 31 | gui.getController().openEnigmaMappings(getFile(args[1])); |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | // DEBUG | 34 | // DEBUG |
diff --git a/src/main/java/cuchaz/enigma/bytecode/ClassRenamer.java b/src/main/java/cuchaz/enigma/bytecode/ClassRenamer.java index 944e486b..4a77eec1 100644 --- a/src/main/java/cuchaz/enigma/bytecode/ClassRenamer.java +++ b/src/main/java/cuchaz/enigma/bytecode/ClassRenamer.java | |||
| @@ -241,10 +241,7 @@ public class ClassRenamer { | |||
| 241 | private static String renameClassSignature(String signature, ReplacerClassMap map) { | 241 | private static String renameClassSignature(String signature, ReplacerClassMap map) { |
| 242 | try { | 242 | try { |
| 243 | ClassSignature type = renameType(SignatureAttribute.toClassSignature(signature), map); | 243 | ClassSignature type = renameType(SignatureAttribute.toClassSignature(signature), map); |
| 244 | if (type != null) { | 244 | return type.encode(); |
| 245 | return type.encode(); | ||
| 246 | } | ||
| 247 | return null; | ||
| 248 | } catch (BadBytecode ex) { | 245 | } catch (BadBytecode ex) { |
| 249 | throw new Error("Can't parse field signature: " + signature); | 246 | throw new Error("Can't parse field signature: " + signature); |
| 250 | } | 247 | } |
| @@ -265,10 +262,7 @@ public class ClassRenamer { | |||
| 265 | private static String renameMethodSignature(String signature, ReplacerClassMap map) { | 262 | private static String renameMethodSignature(String signature, ReplacerClassMap map) { |
| 266 | try { | 263 | try { |
| 267 | MethodSignature type = renameType(SignatureAttribute.toMethodSignature(signature), map); | 264 | MethodSignature type = renameType(SignatureAttribute.toMethodSignature(signature), map); |
| 268 | if (type != null) { | 265 | return type.encode(); |
| 269 | return type.encode(); | ||
| 270 | } | ||
| 271 | return null; | ||
| 272 | } catch (BadBytecode ex) { | 266 | } catch (BadBytecode ex) { |
| 273 | throw new Error("Can't parse method signature: " + signature); | 267 | throw new Error("Can't parse method signature: " + signature); |
| 274 | } | 268 | } |
diff --git a/src/main/java/cuchaz/enigma/bytecode/ClassTranslator.java b/src/main/java/cuchaz/enigma/bytecode/ClassTranslator.java index 8fdd8513..6c05b838 100644 --- a/src/main/java/cuchaz/enigma/bytecode/ClassTranslator.java +++ b/src/main/java/cuchaz/enigma/bytecode/ClassTranslator.java | |||
| @@ -68,6 +68,8 @@ public class ClassTranslator { | |||
| 68 | } | 68 | } |
| 69 | } | 69 | } |
| 70 | break; | 70 | break; |
| 71 | default: | ||
| 72 | break; | ||
| 71 | } | 73 | } |
| 72 | } | 74 | } |
| 73 | 75 | ||
diff --git a/src/main/java/cuchaz/enigma/gui/Gui.java b/src/main/java/cuchaz/enigma/gui/Gui.java index 22694760..262c8b68 100644 --- a/src/main/java/cuchaz/enigma/gui/Gui.java +++ b/src/main/java/cuchaz/enigma/gui/Gui.java | |||
| @@ -79,7 +79,6 @@ public class Gui { | |||
| 79 | public EntryReference<Entry, Entry> m_reference; | 79 | public EntryReference<Entry, Entry> m_reference; |
| 80 | 80 | ||
| 81 | public JFileChooser jarFileChooser; | 81 | public JFileChooser jarFileChooser; |
| 82 | public JFileChooser jsonMappingsFileChooser; | ||
| 83 | public JFileChooser enigmaMappingsFileChooser; | 82 | public JFileChooser enigmaMappingsFileChooser; |
| 84 | 83 | ||
| 85 | public JFileChooser exportSourceFileChooser; | 84 | public JFileChooser exportSourceFileChooser; |
| @@ -107,7 +106,6 @@ public class Gui { | |||
| 107 | 106 | ||
| 108 | // init file choosers | 107 | // init file choosers |
| 109 | this.jarFileChooser = new FileChooserFile(); | 108 | this.jarFileChooser = new FileChooserFile(); |
| 110 | this.jsonMappingsFileChooser = new FileChooserFolder(); | ||
| 111 | 109 | ||
| 112 | 110 | ||
| 113 | this.enigmaMappingsFileChooser = new FileChooserAny(); | 111 | this.enigmaMappingsFileChooser = new FileChooserAny(); |
| @@ -317,9 +315,7 @@ public class Gui { | |||
| 317 | // update menu | 315 | // update menu |
| 318 | this.menuBar.closeJarMenu.setEnabled(true); | 316 | this.menuBar.closeJarMenu.setEnabled(true); |
| 319 | this.menuBar.openEnigmaMappingsMenu.setEnabled(true); | 317 | this.menuBar.openEnigmaMappingsMenu.setEnabled(true); |
| 320 | this.menuBar.openMappingsJsonMenu.setEnabled(true); | ||
| 321 | this.menuBar.saveMappingsMenu.setEnabled(false); | 318 | this.menuBar.saveMappingsMenu.setEnabled(false); |
| 322 | this.menuBar.saveMappingsJsonMenu.setEnabled(true); | ||
| 323 | this.menuBar.saveMappingEnigmaFileMenu.setEnabled(true); | 319 | this.menuBar.saveMappingEnigmaFileMenu.setEnabled(true); |
| 324 | this.menuBar.saveMappingEnigmaDirectoryMenu.setEnabled(true); | 320 | this.menuBar.saveMappingEnigmaDirectoryMenu.setEnabled(true); |
| 325 | this.menuBar.saveMappingsSrgMenu.setEnabled(true); | 321 | this.menuBar.saveMappingsSrgMenu.setEnabled(true); |
| @@ -341,9 +337,7 @@ public class Gui { | |||
| 341 | // update menu | 337 | // update menu |
| 342 | this.menuBar.closeJarMenu.setEnabled(false); | 338 | this.menuBar.closeJarMenu.setEnabled(false); |
| 343 | this.menuBar.openEnigmaMappingsMenu.setEnabled(false); | 339 | this.menuBar.openEnigmaMappingsMenu.setEnabled(false); |
| 344 | this.menuBar.openMappingsJsonMenu.setEnabled(false); | ||
| 345 | this.menuBar.saveMappingsMenu.setEnabled(false); | 340 | this.menuBar.saveMappingsMenu.setEnabled(false); |
| 346 | this.menuBar.saveMappingsJsonMenu.setEnabled(false); | ||
| 347 | this.menuBar.saveMappingEnigmaFileMenu.setEnabled(false); | 341 | this.menuBar.saveMappingEnigmaFileMenu.setEnabled(false); |
| 348 | this.menuBar.saveMappingEnigmaDirectoryMenu.setEnabled(false); | 342 | this.menuBar.saveMappingEnigmaDirectoryMenu.setEnabled(false); |
| 349 | this.menuBar.saveMappingsSrgMenu.setEnabled(false); | 343 | this.menuBar.saveMappingsSrgMenu.setEnabled(false); |
| @@ -363,7 +357,7 @@ public class Gui { | |||
| 363 | } | 357 | } |
| 364 | 358 | ||
| 365 | public void setMappingsFile(File file) { | 359 | public void setMappingsFile(File file) { |
| 366 | this.jsonMappingsFileChooser.setSelectedFile(file); | 360 | this.enigmaMappingsFileChooser.setSelectedFile(file); |
| 367 | this.menuBar.saveMappingsMenu.setEnabled(file != null); | 361 | this.menuBar.saveMappingsMenu.setEnabled(file != null); |
| 368 | } | 362 | } |
| 369 | 363 | ||
| @@ -564,6 +558,8 @@ public class Gui { | |||
| 564 | case KeyEvent.VK_ESCAPE: | 558 | case KeyEvent.VK_ESCAPE: |
| 565 | finishRename(text, false); | 559 | finishRename(text, false); |
| 566 | break; | 560 | break; |
| 561 | default: | ||
| 562 | break; | ||
| 567 | } | 563 | } |
| 568 | } | 564 | } |
| 569 | }); | 565 | }); |
| @@ -668,7 +664,6 @@ public class Gui { | |||
| 668 | } | 664 | } |
| 669 | 665 | ||
| 670 | public void showCalls() { | 666 | public void showCalls() { |
| 671 | |||
| 672 | if (m_reference == null) { | 667 | if (m_reference == null) { |
| 673 | return; | 668 | return; |
| 674 | } | 669 | } |
| @@ -724,9 +719,9 @@ public class Gui { | |||
| 724 | JOptionPane.QUESTION_MESSAGE, null, options, options[2]); | 719 | JOptionPane.QUESTION_MESSAGE, null, options, options[2]); |
| 725 | switch (response) { | 720 | switch (response) { |
| 726 | case JOptionPane.YES_OPTION: // save and exit | 721 | case JOptionPane.YES_OPTION: // save and exit |
| 727 | if (this.jsonMappingsFileChooser.getSelectedFile() != null || this.jsonMappingsFileChooser.showSaveDialog(this.frame) == JFileChooser.APPROVE_OPTION) { | 722 | if (this.enigmaMappingsFileChooser.getSelectedFile() != null || this.enigmaMappingsFileChooser.showSaveDialog(this.frame) == JFileChooser.APPROVE_OPTION) { |
| 728 | try { | 723 | try { |
| 729 | this.controller.saveMappings(this.jsonMappingsFileChooser.getCurrentDirectory()); | 724 | this.controller.saveMappings(this.enigmaMappingsFileChooser.getCurrentDirectory()); |
| 730 | this.frame.dispose(); | 725 | this.frame.dispose(); |
| 731 | } catch (IOException ex) { | 726 | } catch (IOException ex) { |
| 732 | throw new Error(ex); | 727 | throw new Error(ex); |
| @@ -738,6 +733,8 @@ public class Gui { | |||
| 738 | // don't save, exit | 733 | // don't save, exit |
| 739 | this.frame.dispose(); | 734 | this.frame.dispose(); |
| 740 | break; | 735 | break; |
| 736 | default: | ||
| 737 | break; | ||
| 741 | 738 | ||
| 742 | // cancel means do nothing | 739 | // cancel means do nothing |
| 743 | } | 740 | } |
diff --git a/src/main/java/cuchaz/enigma/gui/GuiController.java b/src/main/java/cuchaz/enigma/gui/GuiController.java index d416345b..68f7c56a 100644 --- a/src/main/java/cuchaz/enigma/gui/GuiController.java +++ b/src/main/java/cuchaz/enigma/gui/GuiController.java | |||
| @@ -72,14 +72,6 @@ public class GuiController { | |||
| 72 | refreshCurrentClass(); | 72 | refreshCurrentClass(); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | public void openJsonMappings(File file) throws IOException { | ||
| 76 | this.deobfuscator.setMappings(new MappingsJsonReader().read(file)); | ||
| 77 | this.isDirty = false; | ||
| 78 | this.gui.setMappingsFile(file); | ||
| 79 | refreshClasses(); | ||
| 80 | refreshCurrentClass(); | ||
| 81 | } | ||
| 82 | |||
| 83 | public void saveMappings(File file) throws IOException { | 75 | public void saveMappings(File file) throws IOException { |
| 84 | Mappings mappings = this.deobfuscator.getMappings(); | 76 | Mappings mappings = this.deobfuscator.getMappings(); |
| 85 | switch (mappings.getOriginMappingFormat()) | 77 | switch (mappings.getOriginMappingFormat()) |
| @@ -87,9 +79,6 @@ public class GuiController { | |||
| 87 | case SRG_FILE: | 79 | case SRG_FILE: |
| 88 | saveSRGMappings(file); | 80 | saveSRGMappings(file); |
| 89 | break; | 81 | break; |
| 90 | case JSON_DIRECTORY: | ||
| 91 | saveJsonMappings(file); | ||
| 92 | break; | ||
| 93 | default: | 82 | default: |
| 94 | saveEnigmaMappings(file, Mappings.FormatType.ENIGMA_FILE != mappings.getOriginMappingFormat()); | 83 | saveEnigmaMappings(file, Mappings.FormatType.ENIGMA_FILE != mappings.getOriginMappingFormat()); |
| 95 | break; | 84 | break; |
| @@ -97,11 +86,6 @@ public class GuiController { | |||
| 97 | 86 | ||
| 98 | } | 87 | } |
| 99 | 88 | ||
| 100 | public void saveJsonMappings(File file) throws IOException { | ||
| 101 | new MappingsJsonWriter().write(file, this.deobfuscator.getMappings()); | ||
| 102 | this.isDirty = false; | ||
| 103 | } | ||
| 104 | |||
| 105 | public void saveEnigmaMappings(File file, boolean isDirectoryFormat) throws IOException { | 89 | public void saveEnigmaMappings(File file, boolean isDirectoryFormat) throws IOException { |
| 106 | new MappingsEnigmaWriter().write(file, this.deobfuscator.getMappings(), isDirectoryFormat); | 90 | new MappingsEnigmaWriter().write(file, this.deobfuscator.getMappings(), isDirectoryFormat); |
| 107 | this.isDirty = false; | 91 | this.isDirty = false; |
diff --git a/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java b/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java index e988d74c..038698bf 100644 --- a/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java +++ b/src/main/java/cuchaz/enigma/gui/elements/MenuBar.java | |||
| @@ -17,11 +17,9 @@ public class MenuBar extends JMenuBar { | |||
| 17 | 17 | ||
| 18 | public final JMenuItem closeJarMenu; | 18 | public final JMenuItem closeJarMenu; |
| 19 | 19 | ||
| 20 | public final JMenuItem openMappingsJsonMenu; | ||
| 21 | public final JMenuItem openEnigmaMappingsMenu; | 20 | public final JMenuItem openEnigmaMappingsMenu; |
| 22 | 21 | ||
| 23 | public final JMenuItem saveMappingsMenu; | 22 | public final JMenuItem saveMappingsMenu; |
| 24 | public final JMenuItem saveMappingsJsonMenu; | ||
| 25 | public final JMenuItem saveMappingEnigmaFileMenu; | 23 | public final JMenuItem saveMappingEnigmaFileMenu; |
| 26 | public final JMenuItem saveMappingEnigmaDirectoryMenu; | 24 | public final JMenuItem saveMappingEnigmaDirectoryMenu; |
| 27 | public final JMenuItem saveMappingsSrgMenu; | 25 | public final JMenuItem saveMappingsSrgMenu; |
| @@ -64,6 +62,7 @@ public class MenuBar extends JMenuBar { | |||
| 64 | } | 62 | } |
| 65 | menu.addSeparator(); | 63 | menu.addSeparator(); |
| 66 | JMenu openMenu = new JMenu("Open Mappings..."); | 64 | JMenu openMenu = new JMenu("Open Mappings..."); |
| 65 | menu.add(openMenu); | ||
| 67 | { | 66 | { |
| 68 | JMenuItem item = new JMenuItem("Enigma"); | 67 | JMenuItem item = new JMenuItem("Enigma"); |
| 69 | openMenu.add(item); | 68 | openMenu.add(item); |
| @@ -80,27 +79,12 @@ public class MenuBar extends JMenuBar { | |||
| 80 | }); | 79 | }); |
| 81 | this.openEnigmaMappingsMenu = item; | 80 | this.openEnigmaMappingsMenu = item; |
| 82 | } | 81 | } |
| 83 | menu.add(openMenu); | ||
| 84 | { | ||
| 85 | JMenuItem item = new JMenuItem("JSON (directory)"); | ||
| 86 | openMenu.add(item); | ||
| 87 | item.addActionListener(event -> { | ||
| 88 | if (this.gui.jsonMappingsFileChooser.showOpenDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) { | ||
| 89 | try { | ||
| 90 | this.gui.getController().openJsonMappings(this.gui.jsonMappingsFileChooser.getSelectedFile()); | ||
| 91 | } catch (IOException ex) { | ||
| 92 | throw new Error(ex); | ||
| 93 | } | ||
| 94 | } | ||
| 95 | }); | ||
| 96 | this.openMappingsJsonMenu = item; | ||
| 97 | } | ||
| 98 | { | 82 | { |
| 99 | JMenuItem item = new JMenuItem("Save Mappings"); | 83 | JMenuItem item = new JMenuItem("Save Mappings"); |
| 100 | menu.add(item); | 84 | menu.add(item); |
| 101 | item.addActionListener(event -> { | 85 | item.addActionListener(event -> { |
| 102 | try { | 86 | try { |
| 103 | this.gui.getController().saveMappings(this.gui.jsonMappingsFileChooser.getSelectedFile()); | 87 | this.gui.getController().saveMappings(this.gui.enigmaMappingsFileChooser.getSelectedFile()); |
| 104 | } catch (IOException ex) { | 88 | } catch (IOException ex) { |
| 105 | throw new Error(ex); | 89 | throw new Error(ex); |
| 106 | } | 90 | } |
| @@ -109,13 +93,15 @@ public class MenuBar extends JMenuBar { | |||
| 109 | this.saveMappingsMenu = item; | 93 | this.saveMappingsMenu = item; |
| 110 | } | 94 | } |
| 111 | JMenu saveMenu = new JMenu("Save Mappings As..."); | 95 | JMenu saveMenu = new JMenu("Save Mappings As..."); |
| 96 | menu.add(saveMenu); | ||
| 112 | { | 97 | { |
| 113 | JMenuItem item = new JMenuItem("Enigma (single file)"); | 98 | JMenuItem item = new JMenuItem("Enigma (single file)"); |
| 114 | saveMenu.add(item); | 99 | saveMenu.add(item); |
| 115 | item.addActionListener(event -> { | 100 | item.addActionListener(event -> { |
| 116 | if (this.gui.jsonMappingsFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) { | 101 | // TODO: Use a specific file chooser for it |
| 102 | if (this.gui.enigmaMappingsFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) { | ||
| 117 | try { | 103 | try { |
| 118 | this.gui.getController().saveEnigmaMappings(this.gui.jsonMappingsFileChooser.getSelectedFile(), false); | 104 | this.gui.getController().saveEnigmaMappings(this.gui.enigmaMappingsFileChooser.getSelectedFile(), false); |
| 119 | this.saveMappingsMenu.setEnabled(true); | 105 | this.saveMappingsMenu.setEnabled(true); |
| 120 | } catch (IOException ex) { | 106 | } catch (IOException ex) { |
| 121 | throw new Error(ex); | 107 | throw new Error(ex); |
| @@ -128,9 +114,10 @@ public class MenuBar extends JMenuBar { | |||
| 128 | JMenuItem item = new JMenuItem("Enigma (directory)"); | 114 | JMenuItem item = new JMenuItem("Enigma (directory)"); |
| 129 | saveMenu.add(item); | 115 | saveMenu.add(item); |
| 130 | item.addActionListener(event -> { | 116 | item.addActionListener(event -> { |
| 131 | if (this.gui.jsonMappingsFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) { | 117 | // TODO: Use a specific file chooser for it |
| 118 | if (this.gui.enigmaMappingsFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) { | ||
| 132 | try { | 119 | try { |
| 133 | this.gui.getController().saveEnigmaMappings(this.gui.jsonMappingsFileChooser.getSelectedFile(), true); | 120 | this.gui.getController().saveEnigmaMappings(this.gui.enigmaMappingsFileChooser.getSelectedFile(), true); |
| 134 | this.saveMappingsMenu.setEnabled(true); | 121 | this.saveMappingsMenu.setEnabled(true); |
| 135 | } catch (IOException ex) { | 122 | } catch (IOException ex) { |
| 136 | throw new Error(ex); | 123 | throw new Error(ex); |
| @@ -140,29 +127,14 @@ public class MenuBar extends JMenuBar { | |||
| 140 | item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); | 127 | item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)); |
| 141 | this.saveMappingEnigmaDirectoryMenu = item; | 128 | this.saveMappingEnigmaDirectoryMenu = item; |
| 142 | } | 129 | } |
| 143 | menu.add(saveMenu); | ||
| 144 | { | ||
| 145 | JMenuItem item = new JMenuItem("JSON (directory)"); | ||
| 146 | saveMenu.add(item); | ||
| 147 | item.addActionListener(event -> { | ||
| 148 | if (this.gui.jsonMappingsFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) { | ||
| 149 | try { | ||
| 150 | this.gui.getController().saveJsonMappings(this.gui.jsonMappingsFileChooser.getSelectedFile()); | ||
| 151 | this.saveMappingsMenu.setEnabled(true); | ||
| 152 | } catch (IOException ex) { | ||
| 153 | throw new Error(ex); | ||
| 154 | } | ||
| 155 | } | ||
| 156 | }); | ||
| 157 | this.saveMappingsJsonMenu = item; | ||
| 158 | } | ||
| 159 | { | 130 | { |
| 160 | JMenuItem item = new JMenuItem("SRG"); | 131 | JMenuItem item = new JMenuItem("SRG (single file)"); |
| 161 | saveMenu.add(item); | 132 | saveMenu.add(item); |
| 162 | item.addActionListener(event -> { | 133 | item.addActionListener(event -> { |
| 163 | if (this.gui.jsonMappingsFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) { | 134 | // TODO: Use a specific file chooser for it |
| 135 | if (this.gui.enigmaMappingsFileChooser.showSaveDialog(this.gui.getFrame()) == JFileChooser.APPROVE_OPTION) { | ||
| 164 | try { | 136 | try { |
| 165 | this.gui.getController().saveSRGMappings(this.gui.jsonMappingsFileChooser.getSelectedFile()); | 137 | this.gui.getController().saveSRGMappings(this.gui.enigmaMappingsFileChooser.getSelectedFile()); |
| 166 | this.saveMappingsMenu.setEnabled(true); | 138 | this.saveMappingsMenu.setEnabled(true); |
| 167 | } catch (IOException ex) { | 139 | } catch (IOException ex) { |
| 168 | throw new Error(ex); | 140 | throw new Error(ex); |
diff --git a/src/main/java/cuchaz/enigma/gui/panels/PanelEditor.java b/src/main/java/cuchaz/enigma/gui/panels/PanelEditor.java index 6237710e..1c0ee9e5 100644 --- a/src/main/java/cuchaz/enigma/gui/panels/PanelEditor.java +++ b/src/main/java/cuchaz/enigma/gui/panels/PanelEditor.java | |||
| @@ -50,6 +50,8 @@ public class PanelEditor extends JEditorPane { | |||
| 50 | case KeyEvent.VK_T: | 50 | case KeyEvent.VK_T: |
| 51 | gui.popupMenu.toggleMappingMenu.doClick(); | 51 | gui.popupMenu.toggleMappingMenu.doClick(); |
| 52 | break; | 52 | break; |
| 53 | default: | ||
| 54 | break; | ||
| 53 | } | 55 | } |
| 54 | } | 56 | } |
| 55 | }); | 57 | }); |
diff --git a/src/main/java/cuchaz/enigma/json/JsonArgument.java b/src/main/java/cuchaz/enigma/json/JsonArgument.java deleted file mode 100644 index 4600c87b..00000000 --- a/src/main/java/cuchaz/enigma/json/JsonArgument.java +++ /dev/null | |||
| @@ -1,20 +0,0 @@ | |||
| 1 | package cuchaz.enigma.json; | ||
| 2 | |||
| 3 | public class JsonArgument { | ||
| 4 | |||
| 5 | private int index; | ||
| 6 | private String name; | ||
| 7 | |||
| 8 | public JsonArgument(int index, String name) { | ||
| 9 | this.index = index; | ||
| 10 | this.name = name; | ||
| 11 | } | ||
| 12 | |||
| 13 | public int getIndex() { | ||
| 14 | return index; | ||
| 15 | } | ||
| 16 | |||
| 17 | public String getName() { | ||
| 18 | return name; | ||
| 19 | } | ||
| 20 | } | ||
diff --git a/src/main/java/cuchaz/enigma/json/JsonClass.java b/src/main/java/cuchaz/enigma/json/JsonClass.java deleted file mode 100644 index dc646bcb..00000000 --- a/src/main/java/cuchaz/enigma/json/JsonClass.java +++ /dev/null | |||
| @@ -1,58 +0,0 @@ | |||
| 1 | package cuchaz.enigma.json; | ||
| 2 | |||
| 3 | import java.util.ArrayList; | ||
| 4 | import java.util.List; | ||
| 5 | |||
| 6 | public class JsonClass { | ||
| 7 | private String obf; | ||
| 8 | private String name; | ||
| 9 | private List<JsonField> field = new ArrayList<>(); | ||
| 10 | private List<JsonConstructor> constructors = new ArrayList<>(); | ||
| 11 | private List<JsonMethod> method = new ArrayList<>(); | ||
| 12 | private List<JsonClass> innerClass = new ArrayList<>(); | ||
| 13 | |||
| 14 | public JsonClass(String obf, String name) { | ||
| 15 | this.obf = obf; | ||
| 16 | this.name = name; | ||
| 17 | } | ||
| 18 | |||
| 19 | public void addField(JsonField jsonField) { | ||
| 20 | this.field.add(jsonField); | ||
| 21 | } | ||
| 22 | |||
| 23 | public void addConstructor(JsonConstructor jsonConstructor) { | ||
| 24 | this.constructors.add(jsonConstructor); | ||
| 25 | } | ||
| 26 | |||
| 27 | public void addMethod(JsonMethod jsonMethod) { | ||
| 28 | this.method.add(jsonMethod); | ||
| 29 | } | ||
| 30 | |||
| 31 | public void addInnerClass(JsonClass jsonInnerClass) { | ||
| 32 | this.innerClass.add(jsonInnerClass); | ||
| 33 | } | ||
| 34 | |||
| 35 | public String getObf() { | ||
| 36 | return obf; | ||
| 37 | } | ||
| 38 | |||
| 39 | public String getName() { | ||
| 40 | return name; | ||
| 41 | } | ||
| 42 | |||
| 43 | public List<JsonField> getField() { | ||
| 44 | return field; | ||
| 45 | } | ||
| 46 | |||
| 47 | public List<JsonConstructor> getConstructors() { | ||
| 48 | return constructors; | ||
| 49 | } | ||
| 50 | |||
| 51 | public List<JsonMethod> getMethod() { | ||
| 52 | return method; | ||
| 53 | } | ||
| 54 | |||
| 55 | public List<JsonClass> getInnerClass() { | ||
| 56 | return innerClass; | ||
| 57 | } | ||
| 58 | } | ||
diff --git a/src/main/java/cuchaz/enigma/json/JsonConstructor.java b/src/main/java/cuchaz/enigma/json/JsonConstructor.java deleted file mode 100644 index 8cbecf7b..00000000 --- a/src/main/java/cuchaz/enigma/json/JsonConstructor.java +++ /dev/null | |||
| @@ -1,27 +0,0 @@ | |||
| 1 | package cuchaz.enigma.json; | ||
| 2 | |||
| 3 | import java.util.List; | ||
| 4 | |||
| 5 | public class JsonConstructor { | ||
| 6 | private String signature; | ||
| 7 | private List<JsonArgument> args; | ||
| 8 | private boolean statics; | ||
| 9 | |||
| 10 | public JsonConstructor(String signature, List<JsonArgument> args, boolean statics) { | ||
| 11 | this.signature = signature; | ||
| 12 | this.args = args; | ||
| 13 | this.statics = statics; | ||
| 14 | } | ||
| 15 | |||
| 16 | public String getSignature() { | ||
| 17 | return signature; | ||
| 18 | } | ||
| 19 | |||
| 20 | public List<JsonArgument> getArgs() { | ||
| 21 | return args; | ||
| 22 | } | ||
| 23 | |||
| 24 | public boolean isStatics() { | ||
| 25 | return statics; | ||
| 26 | } | ||
| 27 | } | ||
diff --git a/src/main/java/cuchaz/enigma/json/JsonField.java b/src/main/java/cuchaz/enigma/json/JsonField.java deleted file mode 100644 index c55a5e93..00000000 --- a/src/main/java/cuchaz/enigma/json/JsonField.java +++ /dev/null | |||
| @@ -1,25 +0,0 @@ | |||
| 1 | package cuchaz.enigma.json; | ||
| 2 | |||
| 3 | public class JsonField { | ||
| 4 | private String obf; | ||
| 5 | private String name; | ||
| 6 | private String type; | ||
| 7 | |||
| 8 | public JsonField(String obf, String name, String type) { | ||
| 9 | this.obf = obf; | ||
| 10 | this.name = name; | ||
| 11 | this.type = type; | ||
| 12 | } | ||
| 13 | |||
| 14 | public String getObf() { | ||
| 15 | return this.obf; | ||
| 16 | } | ||
| 17 | |||
| 18 | public String getName() { | ||
| 19 | return this.name; | ||
| 20 | } | ||
| 21 | |||
| 22 | public String getType() { | ||
| 23 | return this.type; | ||
| 24 | } | ||
| 25 | } | ||
diff --git a/src/main/java/cuchaz/enigma/json/JsonMethod.java b/src/main/java/cuchaz/enigma/json/JsonMethod.java deleted file mode 100644 index 7ec44806..00000000 --- a/src/main/java/cuchaz/enigma/json/JsonMethod.java +++ /dev/null | |||
| @@ -1,33 +0,0 @@ | |||
| 1 | package cuchaz.enigma.json; | ||
| 2 | |||
| 3 | import java.util.List; | ||
| 4 | |||
| 5 | public class JsonMethod { | ||
| 6 | private String obf; | ||
| 7 | private String name; | ||
| 8 | private String signature; | ||
| 9 | private List<JsonArgument> args; | ||
| 10 | |||
| 11 | public JsonMethod(String obf, String name, String signature, List<JsonArgument> args) { | ||
| 12 | this.obf = obf; | ||
| 13 | this.name = name; | ||
| 14 | this.signature = signature; | ||
| 15 | this.args = args; | ||
| 16 | } | ||
| 17 | |||
| 18 | public String getObf() { | ||
| 19 | return obf; | ||
| 20 | } | ||
| 21 | |||
| 22 | public String getName() { | ||
| 23 | return name; | ||
| 24 | } | ||
| 25 | |||
| 26 | public String getSignature() { | ||
| 27 | return signature; | ||
| 28 | } | ||
| 29 | |||
| 30 | public List<JsonArgument> getArgs() { | ||
| 31 | return args; | ||
| 32 | } | ||
| 33 | } | ||
diff --git a/src/main/java/cuchaz/enigma/mapping/Mappings.java b/src/main/java/cuchaz/enigma/mapping/Mappings.java index 1f4ca02c..538c67e8 100644 --- a/src/main/java/cuchaz/enigma/mapping/Mappings.java +++ b/src/main/java/cuchaz/enigma/mapping/Mappings.java | |||
| @@ -160,6 +160,6 @@ public class Mappings { | |||
| 160 | 160 | ||
| 161 | public enum FormatType | 161 | public enum FormatType |
| 162 | { | 162 | { |
| 163 | JSON_DIRECTORY, ENIGMA_FILE, ENIGMA_DIRECTORY, SRG_FILE | 163 | ENIGMA_FILE, ENIGMA_DIRECTORY, SRG_FILE |
| 164 | } | 164 | } |
| 165 | } | 165 | } |
diff --git a/src/main/java/cuchaz/enigma/mapping/MappingsJsonReader.java b/src/main/java/cuchaz/enigma/mapping/MappingsJsonReader.java deleted file mode 100644 index 8f5bde33..00000000 --- a/src/main/java/cuchaz/enigma/mapping/MappingsJsonReader.java +++ /dev/null | |||
| @@ -1,120 +0,0 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2015 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Lesser General Public | ||
| 5 | * License v3.0 which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/lgpl.html | ||
| 7 | * <p> | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | package cuchaz.enigma.mapping; | ||
| 12 | |||
| 13 | import com.google.common.base.Charsets; | ||
| 14 | import com.google.common.io.Files; | ||
| 15 | import com.google.gson.Gson; | ||
| 16 | import com.google.gson.GsonBuilder; | ||
| 17 | |||
| 18 | import java.io.*; | ||
| 19 | |||
| 20 | import cuchaz.enigma.json.JsonClass; | ||
| 21 | import cuchaz.enigma.throwables.MappingConflict; | ||
| 22 | |||
| 23 | public class MappingsJsonReader { | ||
| 24 | |||
| 25 | public Mappings read(File in) throws IOException { | ||
| 26 | Mappings mappings = new Mappings(Mappings.FormatType.JSON_DIRECTORY); | ||
| 27 | readDirectory(mappings, in); | ||
| 28 | return mappings; | ||
| 29 | } | ||
| 30 | |||
| 31 | public void readDirectory(Mappings mappings, File in) throws IOException { | ||
| 32 | File[] fList = in.listFiles(); | ||
| 33 | if (fList != null) { | ||
| 34 | for (File file : fList) { | ||
| 35 | if (file.isFile() && Files.getFileExtension(file.getName()).equalsIgnoreCase("json")) { | ||
| 36 | readFile(mappings, new BufferedReader(new InputStreamReader(new FileInputStream(file), | ||
| 37 | Charsets.UTF_8))); | ||
| 38 | } else if (file.isDirectory()) { | ||
| 39 | readDirectory(mappings, file.getAbsoluteFile()); | ||
| 40 | } | ||
| 41 | } | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | public void readFile(Mappings mappings, BufferedReader in) throws IOException { | ||
| 46 | StringBuilder buf = new StringBuilder(); | ||
| 47 | String line; | ||
| 48 | while ((line = in.readLine()) != null) { | ||
| 49 | buf.append(line); | ||
| 50 | } | ||
| 51 | |||
| 52 | Gson gson = new GsonBuilder().setPrettyPrinting().create(); | ||
| 53 | JsonClass jsonClass = gson.fromJson(buf.toString(), JsonClass.class); | ||
| 54 | try { | ||
| 55 | load(null, jsonClass, mappings); | ||
| 56 | } catch (MappingConflict e) { | ||
| 57 | e.printStackTrace(); | ||
| 58 | } | ||
| 59 | in.close(); | ||
| 60 | } | ||
| 61 | |||
| 62 | public void load(ClassMapping parent, JsonClass jsonClass, Mappings mappings) throws MappingConflict { | ||
| 63 | ClassMapping classMapping = readClass(jsonClass.getObf(), jsonClass.getName()); | ||
| 64 | if (parent != null) { | ||
| 65 | parent.addInnerClassMapping(classMapping); | ||
| 66 | } else { | ||
| 67 | mappings.addClassMapping(classMapping); | ||
| 68 | } | ||
| 69 | jsonClass.getField().forEach(jsonField -> classMapping.addFieldMapping(readField(jsonField.getObf(), jsonField.getName(), jsonField.getType()))); | ||
| 70 | |||
| 71 | jsonClass.getConstructors().forEach(jsonConstructor -> { | ||
| 72 | MethodMapping methodMapping = readMethod(jsonConstructor.isStatics() ? "<clinit>" : "<init>", null, jsonConstructor.getSignature()); | ||
| 73 | jsonConstructor.getArgs().forEach(jsonArgument -> { | ||
| 74 | try { | ||
| 75 | methodMapping.addArgumentMapping(readArgument(jsonArgument.getIndex(), jsonArgument.getName())); | ||
| 76 | } catch (MappingConflict e) { | ||
| 77 | e.printStackTrace(); | ||
| 78 | } | ||
| 79 | }); | ||
| 80 | classMapping.addMethodMapping(methodMapping); | ||
| 81 | }); | ||
| 82 | |||
| 83 | jsonClass.getMethod().forEach(jsonMethod -> { | ||
| 84 | MethodMapping methodMapping = readMethod(jsonMethod.getObf(), jsonMethod.getName(), jsonMethod.getSignature()); | ||
| 85 | jsonMethod.getArgs().forEach(jsonArgument -> { | ||
| 86 | try { | ||
| 87 | methodMapping.addArgumentMapping(readArgument(jsonArgument.getIndex(), jsonArgument.getName())); | ||
| 88 | } catch (MappingConflict e) { | ||
| 89 | e.printStackTrace(); | ||
| 90 | } | ||
| 91 | }); | ||
| 92 | classMapping.addMethodMapping(methodMapping); | ||
| 93 | }); | ||
| 94 | |||
| 95 | jsonClass.getInnerClass().forEach(jsonInnerClasses -> { | ||
| 96 | try { | ||
| 97 | load(classMapping, jsonInnerClasses, mappings); | ||
| 98 | } catch (MappingConflict e) { | ||
| 99 | e.printStackTrace(); | ||
| 100 | } | ||
| 101 | }); | ||
| 102 | } | ||
| 103 | |||
| 104 | private ArgumentMapping readArgument(int index, String name) { | ||
| 105 | return new ArgumentMapping(index, name); | ||
| 106 | } | ||
| 107 | |||
| 108 | private ClassMapping readClass(String obf, String deobf) { | ||
| 109 | return new ClassMapping("none/" + obf, deobf); | ||
| 110 | } | ||
| 111 | |||
| 112 | /* TEMP */ | ||
| 113 | protected FieldMapping readField(String obf, String deobf, String sig) { | ||
| 114 | return new FieldMapping(obf, new Type(sig), deobf); | ||
| 115 | } | ||
| 116 | |||
| 117 | private MethodMapping readMethod(String obf, String deobf, String sig) { | ||
| 118 | return new MethodMapping(obf, new Signature(sig), deobf); | ||
| 119 | } | ||
| 120 | } | ||
diff --git a/src/main/java/cuchaz/enigma/mapping/MappingsJsonWriter.java b/src/main/java/cuchaz/enigma/mapping/MappingsJsonWriter.java deleted file mode 100644 index db95322b..00000000 --- a/src/main/java/cuchaz/enigma/mapping/MappingsJsonWriter.java +++ /dev/null | |||
| @@ -1,101 +0,0 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2015 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Lesser General Public | ||
| 5 | * License v3.0 which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/lgpl.html | ||
| 7 | * <p> | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | package cuchaz.enigma.mapping; | ||
| 12 | |||
| 13 | import com.google.common.base.Charsets; | ||
| 14 | import com.google.gson.Gson; | ||
| 15 | import com.google.gson.GsonBuilder; | ||
| 16 | |||
| 17 | import java.io.*; | ||
| 18 | import java.util.ArrayList; | ||
| 19 | import java.util.Collections; | ||
| 20 | import java.util.List; | ||
| 21 | |||
| 22 | import cuchaz.enigma.json.*; | ||
| 23 | |||
| 24 | public class MappingsJsonWriter { | ||
| 25 | |||
| 26 | public void write(File file, Mappings mappings) throws IOException { | ||
| 27 | if (!file.isDirectory()) { | ||
| 28 | return; | ||
| 29 | } | ||
| 30 | |||
| 31 | String[] entries = file.list(); | ||
| 32 | for (String s : entries) { | ||
| 33 | File currentFile = new File(file.getPath(), s); | ||
| 34 | deleteDirectory(currentFile); | ||
| 35 | } | ||
| 36 | |||
| 37 | Gson gson = new GsonBuilder().setPrettyPrinting().create(); | ||
| 38 | for (ClassMapping classMapping : sorted(mappings.classes())) { | ||
| 39 | if (classMapping.getDeobfName() != null && !classMapping.getDeobfName().equalsIgnoreCase("") && !classMapping.getDeobfName().equalsIgnoreCase("null")) { | ||
| 40 | JsonClass jsonClass = new JsonClass(classMapping.getObfSimpleName(), classMapping.getDeobfName()); | ||
| 41 | write(jsonClass, classMapping); | ||
| 42 | |||
| 43 | File f = new File(file, jsonClass.getName() + ".json"); | ||
| 44 | f.getParentFile().mkdirs(); | ||
| 45 | f.createNewFile(); | ||
| 46 | PrintWriter writer = new PrintWriter(new OutputStreamWriter(new FileOutputStream(f), Charsets.UTF_8)); | ||
| 47 | writer.write(gson.toJson(jsonClass)); | ||
| 48 | writer.close(); | ||
| 49 | } | ||
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | private void write(JsonClass jsonClass, ClassMapping classMapping) { | ||
| 54 | for (ClassMapping innerClassMapping : sorted(classMapping.innerClasses())) { | ||
| 55 | JsonClass innerClass = new JsonClass(classMapping.getObfSimpleName() + "$" + innerClassMapping.getObfSimpleName().replace("nome/", ""), innerClassMapping.getDeobfName()); | ||
| 56 | write(innerClass, innerClassMapping); | ||
| 57 | jsonClass.addInnerClass(innerClass); | ||
| 58 | } | ||
| 59 | |||
| 60 | for (FieldMapping fieldMapping : sorted(classMapping.fields())) { | ||
| 61 | jsonClass.addField(new JsonField(fieldMapping.getObfName(), fieldMapping.getDeobfName(), fieldMapping.getObfType().toString())); | ||
| 62 | } | ||
| 63 | |||
| 64 | for (MethodMapping methodMapping : sorted(classMapping.methods())) { | ||
| 65 | List<JsonArgument> args = new ArrayList<>(); | ||
| 66 | for (ArgumentMapping argumentMapping : sorted(methodMapping.arguments())) { | ||
| 67 | args.add(new JsonArgument(argumentMapping.getIndex(), argumentMapping.getName())); | ||
| 68 | } | ||
| 69 | if (methodMapping.getObfName().contains("<init>") || methodMapping.getObfName().contains("<clinit>")) { | ||
| 70 | jsonClass.addConstructor(new JsonConstructor(methodMapping.getObfSignature().toString(), args, methodMapping.getObfName().contains("<clinit>"))); | ||
| 71 | } else { | ||
| 72 | jsonClass.addMethod(new JsonMethod(methodMapping.getObfName(), methodMapping.getDeobfName(), methodMapping.getObfSignature().toString(), args)); | ||
| 73 | } | ||
| 74 | } | ||
| 75 | } | ||
| 76 | |||
| 77 | private <T extends Comparable<T>> List<T> sorted(Iterable<T> classes) { | ||
| 78 | List<T> out = new ArrayList<>(); | ||
| 79 | for (T t : classes) { | ||
| 80 | out.add(t); | ||
| 81 | } | ||
| 82 | Collections.sort(out); | ||
| 83 | return out; | ||
| 84 | } | ||
| 85 | |||
| 86 | public static boolean deleteDirectory(File directory) { | ||
| 87 | if (directory.exists()) { | ||
| 88 | File[] files = directory.listFiles(); | ||
| 89 | if (null != files) { | ||
| 90 | for (int i = 0; i < files.length; i++) { | ||
| 91 | if (files[i].isDirectory()) { | ||
| 92 | deleteDirectory(files[i]); | ||
| 93 | } else { | ||
| 94 | files[i].delete(); | ||
| 95 | } | ||
| 96 | } | ||
| 97 | } | ||
| 98 | } | ||
| 99 | return (directory.delete()); | ||
| 100 | } | ||
| 101 | } | ||