tools: add shared parent path helper
Move the common parent path extraction helper into tools.c and declare it in net.h. Replace the local implementations in RIGHTS, NDIR and NWTESTS with tool_parent_path(). The helper keeps the existing behavior of uppercasing the path and preserving a trailing volume colon for parent paths such as SYS:. No behavior change.
This commit is contained in:
25
nwtests.c
25
nwtests.c
@@ -91,29 +91,6 @@ static void tests_mask_string(uint8 mask, char *out)
|
||||
out[8] = '\0';
|
||||
}
|
||||
|
||||
static void tests_parent_path(char *dst, char *src, int max)
|
||||
{
|
||||
char tmp[260];
|
||||
char *p;
|
||||
|
||||
tool_upcopy(tmp, src, sizeof(tmp));
|
||||
p = strrchr(tmp, '\\');
|
||||
if (!p) p = strrchr(tmp, ':');
|
||||
|
||||
if (!p) {
|
||||
dst[0] = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
if (*p == ':') {
|
||||
p++;
|
||||
*p = '\0';
|
||||
} else {
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
strmaxcpy(dst, tmp, max - 1);
|
||||
}
|
||||
|
||||
static void tests_print_mask(char *label, int rc, uint8 mask)
|
||||
{
|
||||
@@ -2575,7 +2552,7 @@ static int tests_effright(char *path)
|
||||
tests_print_eff_row("old handle path", newhandle, 0, 0, 0);
|
||||
}
|
||||
|
||||
tests_parent_path(usepath, path, sizeof(usepath));
|
||||
tool_parent_path(usepath, path, sizeof(usepath));
|
||||
newhandle = alloc_temp_dir_handle(dhandle, usepath, 0, &eff_old);
|
||||
if (newhandle >= 0) {
|
||||
dealloc_dir_handle(newhandle);
|
||||
|
||||
Reference in New Issue
Block a user