fix: print bare program name in usage instead of argv[0] path
This commit is contained in:
+10
-4
@@ -6,6 +6,12 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define PROGRAM_NAME "fpack.exe"
|
||||||
|
#else
|
||||||
|
#define PROGRAM_NAME "fpack"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define FPACK_QUIET (1u << 0)
|
#define FPACK_QUIET (1u << 0)
|
||||||
#define FPACK_VERBOSE (1u << 1)
|
#define FPACK_VERBOSE (1u << 1)
|
||||||
#define FPACK_PROGRESS (1u << 2)
|
#define FPACK_PROGRESS (1u << 2)
|
||||||
@@ -200,9 +206,9 @@ static int add_dir(struct fpk_writer *w, const char *dir, size_t base_len)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usage(const char *name)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "usage: %s [-o output.fpk] [-p] [-q] [-v] input_dir\n", name);
|
fprintf(stderr, "usage: %s [-o output.fpk] [-p] [-q] [-v] input_dir\n", PROGRAM_NAME);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,12 +236,12 @@ int main(int argc, char **argv)
|
|||||||
flags |= FPACK_VERBOSE;
|
flags |= FPACK_VERBOSE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage(argv[0]);
|
usage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind != argc - 1)
|
if (optind != argc - 1)
|
||||||
usage(argv[0]);
|
usage();
|
||||||
|
|
||||||
input_dir = argv[optind];
|
input_dir = argv[optind];
|
||||||
output = output_arg ? dup_str(output_arg) : derive_output_name(input_dir);
|
output = output_arg ? dup_str(output_arg) : derive_output_name(input_dir);
|
||||||
|
|||||||
+10
-4
@@ -13,6 +13,12 @@
|
|||||||
#define MKDIR(path) mkdir(path, 0755)
|
#define MKDIR(path) mkdir(path, 0755)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#define PROGRAM_NAME "funpack.exe"
|
||||||
|
#else
|
||||||
|
#define PROGRAM_NAME "funpack"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define FUNPACK_LIST (1u << 0)
|
#define FUNPACK_LIST (1u << 0)
|
||||||
#define FUNPACK_PROGRESS (1u << 1)
|
#define FUNPACK_PROGRESS (1u << 1)
|
||||||
#define FUNPACK_QUIET (1u << 2)
|
#define FUNPACK_QUIET (1u << 2)
|
||||||
@@ -146,9 +152,9 @@ static int extract_entry(const char *out_dir, const fpk_entry_t *entry,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usage(const char *name)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "usage: %s [-d output_dir] [-l] [-p] [-q] [-v] input.fpk\n", name);
|
fprintf(stderr, "usage: %s [-d output_dir] [-l] [-p] [-q] [-v] input.fpk\n", PROGRAM_NAME);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,12 +186,12 @@ int main(int argc, char **argv)
|
|||||||
flags |= FUNPACK_VERBOSE;
|
flags |= FUNPACK_VERBOSE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage(argv[0]);
|
usage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind != argc - 1)
|
if (optind != argc - 1)
|
||||||
usage(argv[0]);
|
usage();
|
||||||
|
|
||||||
input = argv[optind];
|
input = argv[optind];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user