Skip to content

Commit

Permalink
Fix losing path information when trying to load file
Browse files Browse the repository at this point in the history
Signed-off-by: TheSilkMiner <thesilkminer@outlook.com>
  • Loading branch information
TheSilkMiner committed Feb 27, 2022
1 parent 52e2063 commit ccf4514
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,13 @@ static ScriptFile of(final String name, final Stream<String> lines, final RunInf
return new ScriptFile(name, data.getSecond(), data.getFirst(), info);
}

static ScriptFile of(final Path file, final RunInfo info, final Collection<IPreprocessor> preprocessors) {

return of(file.toString(), lines(file), info, preprocessors);
}

static ScriptFile of(final Path baseDirectory, final Path file, final RunInfo info, final Collection<IPreprocessor> preprocessors) {

if(!verifyChild(baseDirectory, file)) {
throw new IllegalArgumentException("File " + file + " is not contained within " + baseDirectory);
}
return of(baseDirectory.toAbsolutePath().relativize(file.toAbsolutePath()), info, preprocessors);
final String name = baseDirectory.toAbsolutePath().relativize(file.toAbsolutePath()).toString();
return of(name, lines(file), info, preprocessors);
}

private static boolean verifyChild(final Path parent, final Path file) {
Expand Down

0 comments on commit ccf4514

Please sign in to comment.