Skip to content

Commit

Permalink
Apply hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
sven1103 committed May 31, 2024
1 parent 12abdf0 commit 03e70b2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,32 @@ public static void evaluateExistenceAndDirectory(File file) throws IOException {
}
}

/**
* Convenience method that checks if file can be read and executed by the application.
*
* @param file the path of the file of interest to evaluate
* @throws IOException if neither of the evaluated conditions are failing
* @since 1.0.0
*/
public static void evaluateReadAndExecutablePermission(Path file) throws IOException {
evaluateReadAndExecutablePermission(file.toFile());
}

/**
* Convenience method that checks if file can be read and executed by the application.
*
* @param file the file of interest to evaluate
* @throws IOException if neither of the evaluated conditions are failing
* @since 1.0.0
*/
public static void evaluateReadAndExecutablePermission(File file) throws IOException {
if (!file.canExecute()) {
throw new IOException("Cannot execute file " + file);
}
if (!file.canRead()) {
throw new IOException("Cannot read file " + file);
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public ScannerConfiguration(String scannerDirectory, int interval, String[] igno
throw new IllegalArgumentException("Interval must be greater than 0");
}
AccessRightsEvaluation.evaluateExistenceAndDirectory(this.scannerDirectory);
AccessRightsEvaluation.evaluateWriteAndExecutablePermission(this.scannerDirectory);
AccessRightsEvaluation.evaluateReadAndExecutablePermission(this.scannerDirectory);
this.scanInterval = interval;
this.ignore = Arrays.copyOf(Objects.requireNonNull(ignore), ignore.length);
}
Expand Down

0 comments on commit 03e70b2

Please sign in to comment.