java-decompiler: check for non-existent files

master
Roman Shevchenko 10 years ago
parent 89b40fd28a
commit 1fde78b6f1
  1. 27
      src/org/jetbrains/java/decompiler/main/decompiler/ConsoleDecompiler.java

@ -42,8 +42,8 @@ public class ConsoleDecompiler implements IBytecodeProvider, IResultSaver {
} }
Map<String, Object> mapOptions = new HashMap<String, Object>(); Map<String, Object> mapOptions = new HashMap<String, Object>();
List<String> lstSources = new ArrayList<String>(); List<File> lstSources = new ArrayList<File>();
List<String> lstLibraries = new ArrayList<String>(); List<File> lstLibraries = new ArrayList<File>();
boolean isOption = true; boolean isOption = true;
for (int i = 0; i < args.length - 1; ++i) { // last parameter - destination for (int i = 0; i < args.length - 1; ++i) { // last parameter - destination
@ -65,10 +65,10 @@ public class ConsoleDecompiler implements IBytecodeProvider, IResultSaver {
isOption = false; isOption = false;
if (arg.startsWith("-e=")) { if (arg.startsWith("-e=")) {
lstLibraries.add(arg.substring(3)); addPath(lstLibraries, arg.substring(3));
} }
else { else {
lstSources.add(arg); addPath(lstSources, arg);
} }
} }
} }
@ -87,16 +87,27 @@ public class ConsoleDecompiler implements IBytecodeProvider, IResultSaver {
PrintStreamLogger logger = new PrintStreamLogger(System.out); PrintStreamLogger logger = new PrintStreamLogger(System.out);
ConsoleDecompiler decompiler = new ConsoleDecompiler(destination, mapOptions, logger); ConsoleDecompiler decompiler = new ConsoleDecompiler(destination, mapOptions, logger);
for (String source : lstSources) { for (File source : lstSources) {
decompiler.addSpace(new File(source), true); decompiler.addSpace(source, true);
} }
for (String library : lstLibraries) { for (File library : lstLibraries) {
decompiler.addSpace(new File(library), false); decompiler.addSpace(library, false);
} }
decompiler.decompileContext(); decompiler.decompileContext();
} }
@SuppressWarnings("UseOfSystemOutOrSystemErr")
private static void addPath(List<File> list, String path) {
File file = new File(path);
if (file.exists()) {
list.add(file);
}
else {
System.out.println("warn: missing '" + path + "', ignored");
}
}
// ******************************************************************* // *******************************************************************
// Implementation // Implementation
// ******************************************************************* // *******************************************************************

Loading…
Cancel
Save