diff --git a/tools/fpack.c b/tools/fpack.c index 717b5c3..c7b80f0 100644 --- a/tools/fpack.c +++ b/tools/fpack.c @@ -59,17 +59,23 @@ static char *join_path(const char *dir, const char *name) 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) { size_t end = strlen(path); size_t start; char *out; - while (end > 0 && path[end - 1] == '/') + while (end > 0 && IS_PATH_SEP(path[end - 1])) end--; start = end; - while (start > 0 && path[start - 1] != '/') + while (start > 0 && !IS_PATH_SEP(path[start - 1])) start--; 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); 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--; w = fpk_writer_open(output);