fix: recognize backslash separators in fpack basename/relpath (Windows only)

This commit is contained in:
2026-09-15 12:43:58 +02:00
parent bfba351ac2
commit 01aebb3f31
+9 -3
View File
@@ -59,17 +59,23 @@ static char *join_path(const char *dir, const char *name)
return out; return out;
} }
#ifdef _WIN32
#define IS_PATH_SEP(c) ((c) == '/' || (c) == '\\')
#else
#define IS_PATH_SEP(c) ((c) == '/')
#endif
static char *basename_dup(const char *path) static char *basename_dup(const char *path)
{ {
size_t end = strlen(path); size_t end = strlen(path);
size_t start; size_t start;
char *out; char *out;
while (end > 0 && path[end - 1] == '/') while (end > 0 && IS_PATH_SEP(path[end - 1]))
end--; end--;
start = end; start = end;
while (start > 0 && path[start - 1] != '/') while (start > 0 && !IS_PATH_SEP(path[start - 1]))
start--; start--;
out = malloc(end - start + 1); out = malloc(end - start + 1);
@@ -262,7 +268,7 @@ int main(int argc, char **argv)
output = output_arg ? dup_str(output_arg) : derive_output_name(input_dir); output = output_arg ? dup_str(output_arg) : derive_output_name(input_dir);
base_len = strlen(input_dir); base_len = strlen(input_dir);
while (base_len > 0 && input_dir[base_len - 1] == '/') while (base_len > 0 && IS_PATH_SEP(input_dir[base_len - 1]))
base_len--; base_len--;
w = fpk_writer_open(output); w = fpk_writer_open(output);