Fix paths
During a check, paths should be relative to the input file During normal operation paths are relative to CWD unless they are absolute
This commit is contained in:
parent
ba1d1f7d69
commit
172ba6811c
1 changed files with 6 additions and 5 deletions
11
src/sums.d
11
src/sums.d
|
@ -24,6 +24,7 @@ import tiger;
|
|||
import std.exception;
|
||||
import std.format;
|
||||
import std.array : appender;
|
||||
import std.path;
|
||||
|
||||
private void writeError (string parFile, string parMessage) {
|
||||
stderr.writefln("tigersum: %s: %s", parFile, parMessage);
|
||||
|
@ -37,7 +38,7 @@ void calculateSums (in string[] parFiles, in string parCWD, bool parTiger2, stri
|
|||
ulong[] read_buff = new ulong[READ_BUFF_BLOCKS * 64 / ulong.sizeof];
|
||||
|
||||
foreach (file_name; parFiles) {
|
||||
const auto curr_path = parCWD ~ file_name;
|
||||
const auto curr_path = buildPath(parCWD, file_name);
|
||||
File curr_file;
|
||||
try {
|
||||
curr_file = File(curr_path, parFileMode);
|
||||
|
@ -62,7 +63,7 @@ void calculateSums (in string[] parFiles, in string parCWD, bool parTiger2, stri
|
|||
}
|
||||
}
|
||||
|
||||
bool checkSums (in string parFile, in string parCWD, bool parTiger2, string parFileMode) {
|
||||
bool checkSums (in string parFile, in string parRoot, bool parTiger2, string parFileMode) {
|
||||
File curr_list = File(parFile, "r");
|
||||
bool ret_val = true;
|
||||
const auto reg_bsd = r"^tiger \((.+)\)\s*=\s*([a-fA-F0-9]{48})$";
|
||||
|
@ -88,7 +89,7 @@ bool checkSums (in string parFile, in string parCWD, bool parTiger2, string parF
|
|||
const string capt_filename = cast(string)m.captures[index_file];
|
||||
writef("%s: ", capt_filename);
|
||||
|
||||
const string curr_path = parCWD ~ capt_filename;
|
||||
const string curr_path = buildPath(parRoot, capt_filename);
|
||||
File curr_file;
|
||||
try {
|
||||
curr_file = File(curr_path, parFileMode);
|
||||
|
@ -135,8 +136,8 @@ bool checkSums (in string parFile, in string parCWD, bool parTiger2, string parF
|
|||
bool checkSums (in string[] parFiles, in string parCWD, bool parTiger2, string parFileMode) {
|
||||
bool ret_val = true;
|
||||
foreach (file_name; parFiles) {
|
||||
const auto curr_path = parCWD ~ file_name;
|
||||
ret_val &= checkSums(curr_path, parCWD, parTiger2, parFileMode);
|
||||
string curr_path = buildPath(parCWD, file_name);
|
||||
ret_val &= checkSums(curr_path, dirName(curr_path), parTiger2, parFileMode);
|
||||
}
|
||||
return ret_val;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue