summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2021-01-20 17:46:03 -0500
committer AJR <ajrhacker@users.noreply.github.com>2021-01-20 18:06:15 -0500
commit91921618c2e06bd0ed073b8efccd31a127c9012d (patch)
treed3958b32d8db82540cd31083766b22991eb8e8ae /src/tools
parentc691b79cce315acdfabe1901cb2b5a1e39957bc1 (diff)
Much more core std::string_view modernization
- Remove corestr.h from emu.h; update a few source files to not use it at all - Change strtrimspace, strtrimrightspace and core_filename_extract_* to be pure functions taking a std::string_view by value and returning the same type - Change strmakeupper and strmakelower to be pure functions taking a std::string_view and constructing a std::string - Remove the string-modifying version of zippath_parent - Change tag-based lookup functions in device_t to take std::string_view instead of const std::string & or const char * - Remove the subdevice tag cache from device_t (since device finders are now recommended) and replace it with a map covering directly owned subdevices only - Move the working directory setup method out of device_image_interface (only the UI seems to actually use the full version of this) - Change output_manager to use std::string_view for output name arguments - Change core_options to accept std::string_view for most name and value arguments (return values are still C strings for now) - Change miscellaneous other functions to accept std::string_view arguments - Remove a few string accessor macros from romload.h - Remove many unnecessary c_str() calls from logging/error messages
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/chdman.cpp16
-rw-r--r--src/tools/imgtool/imgtool.cpp2
-rw-r--r--src/tools/imgtool/main.cpp4
-rw-r--r--src/tools/imgtool/stream.cpp3
-rw-r--r--src/tools/split.cpp6
5 files changed, 14 insertions, 17 deletions
diff --git a/src/tools/chdman.cpp b/src/tools/chdman.cpp
index 6bd15339b62..c4cf8302aa3 100644
--- a/src/tools/chdman.cpp
+++ b/src/tools/chdman.cpp
@@ -1270,7 +1270,7 @@ static void compress_common(chd_file_compressor &chd)
// to a CUE file
//-------------------------------------------------
-void output_track_metadata(int mode, util::core_file &file, int tracknum, const cdrom_track_info &info, const char *filename, uint32_t frameoffs, uint64_t discoffs)
+void output_track_metadata(int mode, util::core_file &file, int tracknum, const cdrom_track_info &info, const std::string &filename, uint32_t frameoffs, uint64_t discoffs)
{
if (mode == MODE_GDI)
{
@@ -1318,14 +1318,14 @@ void output_track_metadata(int mode, util::core_file &file, int tracknum, const
size = 2352;
break;
}
- bool needquote = strchr(filename, ' ') != nullptr;
- file.printf("%d %d %d %d %s%s%s %d\n", tracknum+1, frameoffs, mode, size, needquote?"\"":"", filename, needquote?"\"":"", discoffs);
+ bool needquote = filename.find(' ') != std::string::npos;
+ file.printf("%d %d %d %d %s%s%s %d\n", tracknum+1, frameoffs, mode, size, needquote?"\"":"", filename.c_str(), needquote?"\"":"", discoffs);
}
else if (mode == MODE_CUEBIN)
{
// first track specifies the file
if (tracknum == 0)
- file.printf("FILE \"%s\" BINARY\n", filename);
+ file.printf("FILE \"%s\" BINARY\n", filename.c_str());
// determine submode
std::string tempstr;
@@ -1404,9 +1404,9 @@ void output_track_metadata(int mode, util::core_file &file, int tracknum, const
// all tracks but the first one have a file offset
if (tracknum > 0)
- file.printf("DATAFILE \"%s\" #%d %s // length in bytes: %d\n", filename, uint32_t(discoffs), msf_string_from_frames(info.frames), info.frames * (info.datasize + info.subsize));
+ file.printf("DATAFILE \"%s\" #%d %s // length in bytes: %d\n", filename.c_str(), uint32_t(discoffs), msf_string_from_frames(info.frames), info.frames * (info.datasize + info.subsize));
else
- file.printf("DATAFILE \"%s\" %s // length in bytes: %d\n", filename, msf_string_from_frames(info.frames), info.frames * (info.datasize + info.subsize));
+ file.printf("DATAFILE \"%s\" %s // length in bytes: %d\n", filename.c_str(), msf_string_from_frames(info.frames), info.frames * (info.datasize + info.subsize));
// tracks with pregaps get a START marker too
if (info.pregap > 0)
@@ -2491,11 +2491,11 @@ static void do_extract_cd(parameters_map &params)
const cdrom_track_info &trackinfo = toc->tracks[tracknum];
if (mode == MODE_GDI)
{
- output_track_metadata(mode, *output_toc_file, tracknum, trackinfo, core_filename_extract_base(trackbin_name).c_str(), discoffs, outputoffs);
+ output_track_metadata(mode, *output_toc_file, tracknum, trackinfo, std::string(core_filename_extract_base(trackbin_name)), discoffs, outputoffs);
}
else
{
- output_track_metadata(mode, *output_toc_file, tracknum, trackinfo, core_filename_extract_base(*output_bin_file_str).c_str(), discoffs, outputoffs);
+ output_track_metadata(mode, *output_toc_file, tracknum, trackinfo, std::string(core_filename_extract_base(*output_bin_file_str)), discoffs, outputoffs);
}
// If this is bin/cue output and the CHD contains subdata, warn the user and don't include
diff --git a/src/tools/imgtool/imgtool.cpp b/src/tools/imgtool/imgtool.cpp
index 2b2e6c62b08..6d14c90a369 100644
--- a/src/tools/imgtool/imgtool.cpp
+++ b/src/tools/imgtool/imgtool.cpp
@@ -1884,7 +1884,7 @@ imgtoolerr_t imgtool::partition::put_file(const char *newfname, const char *fork
if (!newfname)
{
- basename = core_filename_extract_base(source);
+ basename = std::string(core_filename_extract_base(source));
newfname = basename.c_str();
}
diff --git a/src/tools/imgtool/main.cpp b/src/tools/imgtool/main.cpp
index e0ff03cca62..360f015b233 100644
--- a/src/tools/imgtool/main.cpp
+++ b/src/tools/imgtool/main.cpp
@@ -29,7 +29,7 @@
static void writeusage(std::wostream &output, bool write_word_usage, const struct command *c, char *argv[])
{
- std::string cmdname = core_filename_extract_base(argv[0]);
+ std::string cmdname(core_filename_extract_base(argv[0]));
util::stream_format(output,
L"%s %s %s %s\n",
@@ -873,7 +873,7 @@ int main(int argc, char *argv[])
int result;
const struct command *c;
const char *sample_format = "coco_jvc_rsdos";
- std::string cmdname = core_filename_extract_base(argv[0]);
+ std::string cmdname(core_filename_extract_base(argv[0]));
#ifdef _WIN32
_setmode(_fileno(stdout), _O_U8TEXT);
diff --git a/src/tools/imgtool/stream.cpp b/src/tools/imgtool/stream.cpp
index da4cf87f8eb..bb0d95614f3 100644
--- a/src/tools/imgtool/stream.cpp
+++ b/src/tools/imgtool/stream.cpp
@@ -147,8 +147,7 @@ imgtool::stream::ptr imgtool::stream::open(const std::string &filename, int read
char c;
// maybe we are just a ZIP?
- std::string ext = core_filename_extract_extension(filename);
- if (!core_stricmp(ext.c_str(), ".zip"))
+ if (core_filename_ends_with(filename, ".zip"))
return open_zip(filename, nullptr, read_or_write);
util::core_file::ptr f = nullptr;
diff --git a/src/tools/split.cpp b/src/tools/split.cpp
index c3f4489f225..f8a8eb79234 100644
--- a/src/tools/split.cpp
+++ b/src/tools/split.cpp
@@ -236,8 +236,7 @@ static int join_file(const char *filename, const char *outname, int write_output
fprintf(stderr, "Fatal error: corrupt or incomplete split file at line:\n%s\n", buffer);
goto cleanup;
}
- outfilename.assign(buffer + 10);
- strtrimspace(outfilename);
+ outfilename.assign(strtrimspace(buffer + 10));
// compute the base path
basepath.assign(filename);
@@ -295,8 +294,7 @@ static int join_file(const char *filename, const char *outname, int write_output
goto cleanup;
}
expectedhash.assign(buffer + 5, SHA1_DIGEST_SIZE * 2);
- infilename.assign(buffer + 5 + SHA1_DIGEST_SIZE * 2 + 6);
- strtrimspace(infilename);
+ infilename.assign(strtrimspace(buffer + 5 + SHA1_DIGEST_SIZE * 2 + 6));
printf(" Reading file '%s'...", infilename.c_str());