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>();
List<String> lstSources = new ArrayList<String>();
List<String> lstLibraries = new ArrayList<String>();
List<File> lstSources = new ArrayList<File>();
List<File> lstLibraries = new ArrayList<File>();
boolean isOption = true;
for (int i = 0; i < args.length - 1; ++i) { // last parameter - destination
@ -65,10 +65,10 @@ public class ConsoleDecompiler implements IBytecodeProvider, IResultSaver {
isOption = false;
if (arg.startsWith("-e=")) {
lstLibraries.add(arg.substring(3));
addPath(lstLibraries, arg.substring(3));
}
else {
lstSources.add(arg);
addPath(lstSources, arg);
}
}
}
@ -87,16 +87,27 @@ public class ConsoleDecompiler implements IBytecodeProvider, IResultSaver {
PrintStreamLogger logger = new PrintStreamLogger(System.out);
ConsoleDecompiler decompiler = new ConsoleDecompiler(destination, mapOptions, logger);
for (String source : lstSources) {
decompiler.addSpace(new File(source), true);
for (File source : lstSources) {
decompiler.addSpace(source, true);
}
for (String library : lstLibraries) {
decompiler.addSpace(new File(library), false);
for (File library : lstLibraries) {
decompiler.addSpace(library, false);
}
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
// *******************************************************************

Loading…
Cancel
Save