mirror of
https://github.com/holub/mame
synced 2025-06-05 20:33:45 +03:00
Merge pull request #1446 from npwoods/retire_imgtool_basename
Retired imgtool_basename(), in favor of core_filename_extract_base()
This commit is contained in:
commit
651808f6be
@ -164,23 +164,6 @@ static imgtoolerr_t markerrorsource(imgtoolerr_t err)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *imgtool_basename(char *filename)
|
|
||||||
{
|
|
||||||
char *c;
|
|
||||||
|
|
||||||
// NULL begets NULL
|
|
||||||
if (!filename)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
// start at the end and return when we hit a slash or colon
|
|
||||||
for (c = filename + strlen(filename) - 1; c >= filename; c--)
|
|
||||||
if (*c == '\\' || *c == '/' || *c == ':')
|
|
||||||
return c + 1;
|
|
||||||
|
|
||||||
// otherwise, return the whole thing
|
|
||||||
return filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
internal_error - debug function for raising
|
internal_error - debug function for raising
|
||||||
internal errors
|
internal errors
|
||||||
@ -2102,9 +2085,13 @@ imgtoolerr_t imgtool_partition_put_file(imgtool_partition *partition, const char
|
|||||||
imgtool_stream *f = nullptr;
|
imgtool_stream *f = nullptr;
|
||||||
imgtool_charset charset;
|
imgtool_charset charset;
|
||||||
char *alloc_newfname = nullptr;
|
char *alloc_newfname = nullptr;
|
||||||
|
std::string basename;
|
||||||
|
|
||||||
if (!newfname)
|
if (!newfname)
|
||||||
newfname = (const char *) imgtool_basename((char *) source);
|
{
|
||||||
|
basename = core_filename_extract_base(source);
|
||||||
|
newfname = basename.c_str();
|
||||||
|
}
|
||||||
|
|
||||||
charset = (imgtool_charset) (int) imgtool_partition_get_info_int(partition, IMGTOOLINFO_INT_CHARSET);
|
charset = (imgtool_charset) (int) imgtool_partition_get_info_int(partition, IMGTOOLINFO_INT_CHARSET);
|
||||||
if (charset != IMGTOOL_CHARSET_UTF8)
|
if (charset != IMGTOOL_CHARSET_UTF8)
|
||||||
|
@ -84,7 +84,6 @@ const imgtool_module *imgtool_find_module(const char *modulename);
|
|||||||
const imgtool::library::modulelist &imgtool_get_modules();
|
const imgtool::library::modulelist &imgtool_get_modules();
|
||||||
imgtool_module_features imgtool_get_module_features(const imgtool_module *module);
|
imgtool_module_features imgtool_get_module_features(const imgtool_module *module);
|
||||||
void imgtool_warn(const char *format, ...) ATTR_PRINTF(1,2);
|
void imgtool_warn(const char *format, ...) ATTR_PRINTF(1,2);
|
||||||
char *imgtool_basename(char *filename);
|
|
||||||
|
|
||||||
/* ----- image management ----- */
|
/* ----- image management ----- */
|
||||||
imgtoolerr_t imgtool_identify_file(const char *filename, imgtool_module **modules, size_t count);
|
imgtoolerr_t imgtool_identify_file(const char *filename, imgtool_module **modules, size_t count);
|
||||||
|
@ -23,9 +23,10 @@
|
|||||||
|
|
||||||
static void writeusage(FILE *f, int write_word_usage, const struct command *c, char *argv[])
|
static void writeusage(FILE *f, int write_word_usage, const struct command *c, char *argv[])
|
||||||
{
|
{
|
||||||
|
std::string cmdname = core_filename_extract_base(argv[0]);
|
||||||
fprintf(f, "%s %s %s %s\n",
|
fprintf(f, "%s %s %s %s\n",
|
||||||
(write_word_usage ? "Usage:" : " "),
|
(write_word_usage ? "Usage:" : " "),
|
||||||
imgtool_basename(argv[0]),
|
cmdname.c_str(),
|
||||||
c->name,
|
c->name,
|
||||||
c->usage ? c->usage : "");
|
c->usage ? c->usage : "");
|
||||||
}
|
}
|
||||||
@ -870,6 +871,7 @@ int CLIB_DECL main(int argc, char *argv[])
|
|||||||
int result;
|
int result;
|
||||||
const struct command *c;
|
const struct command *c;
|
||||||
const char *sample_format = "coco_jvc_rsdos";
|
const char *sample_format = "coco_jvc_rsdos";
|
||||||
|
std::string cmdname = core_filename_extract_base(argv[0]);
|
||||||
|
|
||||||
#ifdef MAME_DEBUG
|
#ifdef MAME_DEBUG
|
||||||
if (imgtool_validitychecks())
|
if (imgtool_validitychecks())
|
||||||
@ -929,9 +931,9 @@ int CLIB_DECL main(int argc, char *argv[])
|
|||||||
fprintf(stderr, "<imagename> is the image filename; can specify a ZIP file for image name\n");
|
fprintf(stderr, "<imagename> is the image filename; can specify a ZIP file for image name\n");
|
||||||
|
|
||||||
fprintf(stderr, "\nExample usage:\n");
|
fprintf(stderr, "\nExample usage:\n");
|
||||||
fprintf(stderr, "\t%s dir %s myimageinazip.zip\n", imgtool_basename(argv[0]), sample_format);
|
fprintf(stderr, "\t%s dir %s myimageinazip.zip\n", cmdname.c_str(), sample_format);
|
||||||
fprintf(stderr, "\t%s get %s myimage.dsk myfile.bin mynewfile.txt\n", imgtool_basename(argv[0]), sample_format);
|
fprintf(stderr, "\t%s get %s myimage.dsk myfile.bin mynewfile.txt\n", cmdname.c_str(), sample_format);
|
||||||
fprintf(stderr, "\t%s getall %s myimage.dsk\n", imgtool_basename(argv[0]), sample_format);
|
fprintf(stderr, "\t%s getall %s myimage.dsk\n", cmdname.c_str(), sample_format);
|
||||||
result = 0;
|
result = 0;
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user