浏览代码

Run some checks on the output path

Baglio Tabifata 4 年之前
父节点
当前提交
a6d0f8f51d
共有 1 个文件被更改,包括 20 次插入0 次删除
  1. 20 0
      src/main/java/info/hkzlab/dupal/analyzer/App.java

+ 20 - 0
src/main/java/info/hkzlab/dupal/analyzer/App.java

@@ -1,5 +1,6 @@
 package info.hkzlab.dupal.analyzer;
 package info.hkzlab.dupal.analyzer;
 
 
+import java.io.File;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.InvocationTargetException;
 
 
 import org.slf4j.*;
 import org.slf4j.*;
@@ -79,5 +80,24 @@ public class App {
         if(args.length >= 4) {
         if(args.length >= 4) {
             outMask = Integer.parseInt(args[3], 16);
             outMask = Integer.parseInt(args[3], 16);
         }
         }
+
+        checkOutPath(outFile);
+    }
+
+    private static void checkOutPath(String path) {
+        File file = new File(path);
+
+        boolean exists = file.exists();
+        boolean isDirectory = file.isDirectory();
+
+        if(isDirectory) {
+            logger.error("Output path " + path + " points to a directory, please specify an output file!");
+            System.exit(-1);
+        }
+
+        if(exists) {
+            logger.error("Output path " + path + " points to an existing file. We're not going to overwrite it!");
+            System.exit(-1);
+        }
     }
     }
 }
 }