diff options
author | 2022-01-04 08:07:50 -0500 | |
---|---|---|
committer | 2022-01-04 08:07:50 -0500 | |
commit | 6e7ff938b03607e868c71977e6b41cdce0b386ee (patch) | |
tree | b18f65cdacc70f466a5c64fb200b54f0b1ec0104 /src/tools/floptool.cpp | |
parent | 92c5f8ae84bd90393ca06ff84138b5ff50f0edb9 (diff) |
Fixing floptool usage message: (#9088)
* Fixing floptool usage message:
- Getting the name of the tool from argv[0] (stop hardcoding floptool.exe)
- Adding missing hddir/hdread/hdwrite declarations
Diffstat (limited to 'src/tools/floptool.cpp')
-rw-r--r-- | src/tools/floptool.cpp | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/src/tools/floptool.cpp b/src/tools/floptool.cpp index 9632fe4eeca..76b24095e8c 100644 --- a/src/tools/floptool.cpp +++ b/src/tools/floptool.cpp @@ -8,6 +8,7 @@ #include "image_handler.h" +#include "corefile.h" #include "corestr.h" #include "ioprocs.h" #include "strformat.h" @@ -26,16 +27,21 @@ static formats_table formats; -static void display_usage() +static void display_usage(const char *first_argument) { + std::string exe_name(core_filename_extract_base(first_argument)); + fprintf(stderr, "Usage: \n"); - fprintf(stderr, " floptool.exe identify <inputfile> [<inputfile> ...] -- Identify an image format\n"); - fprintf(stderr, " floptool.exe flopconvert [input_format|auto] output_format <inputfile> <outputfile> -- Convert a floppy image\n"); - fprintf(stderr, " floptool.exe flopcreate output_format filesystem <outputfile> -- Create a preformatted floppy image\n"); - fprintf(stderr, " floptool.exe flopdir input_format filesystem <image> -- List the contents of a floppy image\n"); - fprintf(stderr, " floptool.exe flopread input_format filesystem <image> <path> <outputfile> -- Extract a file from a floppy image\n"); - fprintf(stderr, " floptool.exe flopwrite input_format filesystem <image> <inputfile> <path> -- Write a file into a floppy image\n"); - fprintf(stderr, " floptool.exe version -- Display the current version of floptool\n"); + fprintf(stderr, " %s identify <inputfile> [<inputfile> ...] -- Identify an image format\n", exe_name.c_str()); + fprintf(stderr, " %s flopconvert [input_format|auto] output_format <inputfile> <outputfile> -- Convert a floppy image\n", exe_name.c_str()); + fprintf(stderr, " %s flopcreate output_format filesystem <outputfile> -- Create a preformatted floppy image\n", exe_name.c_str()); + fprintf(stderr, " %s flopdir input_format filesystem <image> -- List the contents of a floppy image\n", exe_name.c_str()); + fprintf(stderr, " %s flopread input_format filesystem <image> <path> <outputfile> -- Extract a file from a floppy image\n", exe_name.c_str()); + fprintf(stderr, " %s flopwrite input_format filesystem <image> <inputfile> <path> -- Write a file into a floppy image\n", exe_name.c_str()); + fprintf(stderr, " %s hddir filesystem <image> -- List the contents of a hard disk image\n", exe_name.c_str()); + fprintf(stderr, " %s hdread filesystem <image> <path> <outputfile> -- Extract a file from a hard disk image\n", exe_name.c_str()); + fprintf(stderr, " %s hdwrite filesystem <image> <inputfile> <path> -- Write a file into a hard disk image\n", exe_name.c_str()); + fprintf(stderr, " %s version -- Display the current version of floptool\n", exe_name.c_str()); } static void display_formats() @@ -92,14 +98,13 @@ static void display_formats() } } -static void display_full_usage() +static void display_full_usage(char *argv[]) { /* Usage */ fprintf(stderr, "floptool - Generic floppy image manipulation tool for use with MAME\n\n"); - display_usage(); + display_usage(argv[0]); fprintf(stderr, "\n"); display_formats(); - } static int identify(int argc, char *argv[]) @@ -108,7 +113,7 @@ static int identify(int argc, char *argv[]) if(argc<3) { fprintf(stderr, "Missing name of file to identify.\n\n"); - display_usage(); + display_usage(argv[0]); return 1; } @@ -180,7 +185,7 @@ static int flopconvert(int argc, char *argv[]) { if(argc!=6) { fprintf(stderr, "Incorrect number of arguments.\n\n"); - display_usage(); + display_usage(argv[0]); return 1; } @@ -220,7 +225,7 @@ static int flopcreate(int argc, char *argv[]) { if(argc!=5) { fprintf(stderr, "Incorrect number of arguments.\n\n"); - display_usage(); + display_usage(argv[0]); return 1; } @@ -357,7 +362,7 @@ static int flopdir(int argc, char *argv[]) { if(argc!=5) { fprintf(stderr, "Incorrect number of arguments.\n\n"); - display_usage(); + display_usage(argv[0]); return 1; } @@ -396,7 +401,7 @@ static int hddir(int argc, char *argv[]) { if(argc!=4) { fprintf(stderr, "Incorrect number of arguments.\n\n"); - display_usage(); + display_usage(argv[0]); return 1; } @@ -481,7 +486,7 @@ static int flopread(int argc, char *argv[]) { if(argc!=7) { fprintf(stderr, "Incorrect number of arguments.\n\n"); - display_usage(); + display_usage(argv[0]); return 1; } @@ -520,7 +525,7 @@ static int hdread(int argc, char *argv[]) { if(argc!=6) { fprintf(stderr, "Incorrect number of arguments.\n\n"); - display_usage(); + display_usage(argv[0]); return 1; } @@ -602,7 +607,7 @@ static int flopwrite(int argc, char *argv[]) { if(argc!=7) { fprintf(stderr, "Incorrect number of arguments.\n\n"); - display_usage(); + display_usage(argv[0]); return 1; } @@ -649,7 +654,7 @@ static int hdwrite(int argc, char *argv[]) { if(argc!=6) { fprintf(stderr, "Incorrect number of arguments.\n\n"); - display_usage(); + display_usage(argv[0]); return 1; } @@ -688,7 +693,7 @@ int CLIB_DECL main(int argc, char *argv[]) formats.init(); if(argc == 1) { - display_full_usage(); + display_full_usage(argv); return 0; } @@ -715,7 +720,7 @@ int CLIB_DECL main(int argc, char *argv[]) return version(argc, argv); else { fprintf(stderr, "Unknown command '%s'\n\n", argv[1]); - display_usage(); + display_usage(argv[0]); return 1; } } catch(const std::exception &err) { |