only:prependIfNotAbsolute

This commit is contained in:
rusefillc 2024-11-21 17:36:04 -05:00
parent 453cecd81b
commit bb9a9da1f5
1 changed files with 8 additions and 1 deletions

View File

@ -33,7 +33,7 @@ public class IoUtil2 {
}
private static long getCrc32(String fileName) throws IOException {
File file = new File(RootHolder.ROOT + fileName);
File file = new File(prependIfNotAbsolute(RootHolder.ROOT, fileName));
byte[] fileContent = Files.readAllBytes(file.toPath());
for (int i = 0; i < fileContent.length; i++) {
byte aByte = fileContent[i];
@ -45,6 +45,13 @@ public class IoUtil2 {
return c.getValue();
}
private static String prependIfNotAbsolute(String prefix, String fileName) {
if (new File(fileName).isAbsolute()) {
return fileName;
} else {
return prefix + fileName;
}
}
static long getCrc32(List<String> inputFileNames) throws IOException {
// get CRC32 of given input files