|
@@ -13,6 +13,7 @@ import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
import java.util.HashSet;
|
|
import java.util.HashSet;
|
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import de.jplag.options.JPlagOptions;
|
|
import de.jplag.options.JPlagOptions;
|
|
@@ -40,7 +41,7 @@ public class JPlag implements Program {
|
|
|
// ERROR REPORTING:
|
|
// ERROR REPORTING:
|
|
|
private String currentSubmissionName = "<Unknown submission>"; // TODO PB: This should be moved to parseSubmissions(...)
|
|
private String currentSubmissionName = "<Unknown submission>"; // TODO PB: This should be moved to parseSubmissions(...)
|
|
|
private int errors = 0;
|
|
private int errors = 0;
|
|
|
- private ArrayList<String> errorVector = new ArrayList<>(); // Vector of errors that occurred during the execution of the program.
|
|
|
|
|
|
|
+ private List<String> errorVector = new ArrayList<>(); // Vector of errors that occurred during the execution of the program.
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Creates and initializes a JPlag instance, parameterized by a set of options.
|
|
* Creates and initializes a JPlag instance, parameterized by a set of options.
|
|
@@ -149,33 +150,30 @@ public class JPlag implements Program {
|
|
|
* This method checks whether the base code directory value is valid.
|
|
* This method checks whether the base code directory value is valid.
|
|
|
*/
|
|
*/
|
|
|
private void checkBaseCodeOption() throws ExitException {
|
|
private void checkBaseCodeOption() throws ExitException {
|
|
|
- if (!this.options.hasBaseCode()) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- String baseCodePath = this.options.getRootDirectoryName() + File.separator + this.options.getBaseCodeSubmissionName();
|
|
|
|
|
-
|
|
|
|
|
- if (!(new File(this.options.getRootDirectoryName())).exists()) {
|
|
|
|
|
- throw new ExitException("Root directory \"" + this.options.getRootDirectoryName() + "\" doesn't exist!", ExitException.BAD_PARAMETER);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- File f = new File(baseCodePath);
|
|
|
|
|
-
|
|
|
|
|
- if (!f.exists()) {
|
|
|
|
|
- // Base code dir doesn't exist
|
|
|
|
|
- throw new ExitException("Basecode directory \"" + baseCodePath + "\" doesn't exist!", ExitException.BAD_PARAMETER);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (options.hasBaseCode()) {
|
|
|
|
|
+ if (!new File(options.getRootDirectoryName()).exists()) {
|
|
|
|
|
+ throw new ExitException("Root directory \"" + options.getRootDirectoryName() + "\" doesn't exist!", ExitException.BAD_PARAMETER);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if (this.options.getSubdirectoryName() != null && this.options.getSubdirectoryName().length() != 0) {
|
|
|
|
|
- f = new File(baseCodePath, this.options.getSubdirectoryName());
|
|
|
|
|
|
|
+ String baseCode = options.getBaseCodeSubmissionName().replace(File.separator, ""); // trim problematic file separators
|
|
|
|
|
+ if (baseCode.contains(".")) {
|
|
|
|
|
+ throw new ExitException("The basecode directory name \"" + baseCode + "\" cannot contain dots!", ExitException.BAD_PARAMETER);
|
|
|
|
|
+ }
|
|
|
|
|
+ String baseCodePath = options.getRootDirectoryName() + File.separator + baseCode;
|
|
|
|
|
+ if (!new File(baseCodePath).exists()) {
|
|
|
|
|
+ throw new ExitException("Basecode directory \"" + baseCodePath + "\" doesn't exist!", ExitException.BAD_PARAMETER);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if (!f.exists()) {
|
|
|
|
|
- throw new ExitException("Basecode directory doesn't contain" + " the subdirectory \"" + this.options.getSubdirectoryName() + "\"!",
|
|
|
|
|
- ExitException.BAD_PARAMETER);
|
|
|
|
|
|
|
+ String subdirectory = options.getSubdirectoryName();
|
|
|
|
|
+ if (subdirectory != null && subdirectory.length() != 0) {
|
|
|
|
|
+ if (!new File(baseCodePath, subdirectory).exists()) {
|
|
|
|
|
+ throw new ExitException("Basecode directory doesn't contain" + " the subdirectory \"" + subdirectory + "\"!",
|
|
|
|
|
+ ExitException.BAD_PARAMETER);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ options.setBaseCodeSubmissionName(baseCode);
|
|
|
|
|
+ System.out.println("Basecode directory \"" + baseCodePath + "\" will be used");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- System.out.println("Basecode directory \"" + baseCodePath + "\" will be used");
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private ArrayList<Submission> filterValidSubmissions(ArrayList<Submission> submissions) {
|
|
private ArrayList<Submission> filterValidSubmissions(ArrayList<Submission> submissions) {
|