From a7bfc73cfb3f5aac5c7f96a8d969803501a58862 Mon Sep 17 00:00:00 2001 From: Nathan Woods Date: Fri, 29 Jul 2016 20:53:46 -0400 Subject: [PATCH] Changed various string arguments for emu_file::open() from 'const char *' to std::string --- src/emu/diimage.cpp | 6 +++--- src/emu/fileio.cpp | 36 +++++++++++++++--------------------- src/emu/fileio.h | 16 ++++++++-------- src/emu/romload.cpp | 4 ++-- 4 files changed, 28 insertions(+), 34 deletions(-) diff --git a/src/emu/diimage.cpp b/src/emu/diimage.cpp index cbdf4e19a5a..e5497120f5e 100644 --- a/src/emu/diimage.cpp +++ b/src/emu/diimage.cpp @@ -550,7 +550,7 @@ void device_image_interface::battery_load(void *buffer, int length, int fill) /* try to open the battery file and read it in, if possible */ emu_file file(device().machine().options().nvram_directory(), OPEN_FLAG_READ); - filerr = file.open(fname.c_str()); + filerr = file.open(fname); if (filerr == osd_file::error::NONE) bytes_read = file.read(buffer, length); @@ -568,7 +568,7 @@ void device_image_interface::battery_load(void *buffer, int length, void *def_bu // try to open the battery file and read it in, if possible emu_file file(device().machine().options().nvram_directory(), OPEN_FLAG_READ); - filerr = file.open(fname.c_str()); + filerr = file.open(fname); if (filerr == osd_file::error::NONE) bytes_read = file.read(buffer, length); @@ -592,7 +592,7 @@ void device_image_interface::battery_save(const void *buffer, int length) // try to open the battery file and write it out, if possible emu_file file(device().machine().options().nvram_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); - osd_file::error filerr = file.open(fname.c_str()); + osd_file::error filerr = file.open(fname); if (filerr == osd_file::error::NONE) file.write(buffer, length); } diff --git a/src/emu/fileio.cpp b/src/emu/fileio.cpp index 923ea427b3f..2bf548bff6d 100644 --- a/src/emu/fileio.cpp +++ b/src/emu/fileio.cpp @@ -110,7 +110,7 @@ const osd::directory::entry *file_enumerator::next() return nullptr; // open the path - m_curdir = osd::directory::open(m_pathbuffer.c_str()); + m_curdir = osd::directory::open(m_pathbuffer); } // get the next entry from the current directory @@ -240,7 +240,7 @@ util::hash_collection &emu_file::hashes(const char *types) // open - open a file by searching paths //------------------------------------------------- -osd_file::error emu_file::open(const char *name) +osd_file::error emu_file::open(const std::string &name) { // remember the filename and CRC info m_filename = name; @@ -252,28 +252,25 @@ osd_file::error emu_file::open(const char *name) return open_next(); } -osd_file::error emu_file::open(const char *name1, const char *name2) +osd_file::error emu_file::open(const std::string &name1, const std::string &name2) { // concatenate the strings and do a standard open - std::string name = std::string(name1).append(name2); - return open(name.c_str()); + return open(name1 + name2); } -osd_file::error emu_file::open(const char *name1, const char *name2, const char *name3) +osd_file::error emu_file::open(const std::string &name1, const std::string &name2, const std::string &name3) { // concatenate the strings and do a standard open - std::string name = std::string(name1).append(name2).append(name3); - return open(name.c_str()); + return open(name1 + name2 + name3); } -osd_file::error emu_file::open(const char *name1, const char *name2, const char *name3, const char *name4) +osd_file::error emu_file::open(const std::string &name1, const std::string &name2, const std::string &name3, const std::string &name4) { // concatenate the strings and do a standard open - std::string name = std::string(name1).append(name2).append(name3).append(name4); - return open(name.c_str()); + return open(name1 + name2 + name3 + name4); } -osd_file::error emu_file::open(const char *name, UINT32 crc) +osd_file::error emu_file::open(const std::string &name, UINT32 crc) { // remember the filename and CRC info m_filename = name; @@ -285,25 +282,22 @@ osd_file::error emu_file::open(const char *name, UINT32 crc) return open_next(); } -osd_file::error emu_file::open(const char *name1, const char *name2, UINT32 crc) +osd_file::error emu_file::open(const std::string &name1, const std::string &name2, UINT32 crc) { // concatenate the strings and do a standard open - std::string name = std::string(name1).append(name2); - return open(name.c_str(), crc); + return open(name1 + name2, crc); } -osd_file::error emu_file::open(const char *name1, const char *name2, const char *name3, UINT32 crc) +osd_file::error emu_file::open(const std::string &name1, const std::string &name2, const std::string &name3, UINT32 crc) { // concatenate the strings and do a standard open - std::string name = std::string(name1).append(name2).append(name3); - return open(name.c_str(), crc); + return open(name1 + name2 + name3, crc); } -osd_file::error emu_file::open(const char *name1, const char *name2, const char *name3, const char *name4, UINT32 crc) +osd_file::error emu_file::open(const std::string &name1, const std::string &name2, const std::string &name3, const std::string &name4, UINT32 crc) { // concatenate the strings and do a standard open - std::string name = std::string(name1).append(name2).append(name3).append(name4); - return open(name.c_str(), crc); + return open(name1 + name2 + name3 + name4, crc); } diff --git a/src/emu/fileio.h b/src/emu/fileio.h index 7775854ec23..69479bc5a98 100644 --- a/src/emu/fileio.h +++ b/src/emu/fileio.h @@ -101,14 +101,14 @@ public: void set_restrict_to_mediapath(bool rtmp = true) { m_restrict_to_mediapath = rtmp; } // open/close - osd_file::error open(const char *name); - osd_file::error open(const char *name1, const char *name2); - osd_file::error open(const char *name1, const char *name2, const char *name3); - osd_file::error open(const char *name1, const char *name2, const char *name3, const char *name4); - osd_file::error open(const char *name, UINT32 crc); - osd_file::error open(const char *name1, const char *name2, UINT32 crc); - osd_file::error open(const char *name1, const char *name2, const char *name3, UINT32 crc); - osd_file::error open(const char *name1, const char *name2, const char *name3, const char *name4, UINT32 crc); + osd_file::error open(const std::string &name); + osd_file::error open(const std::string &name1, const std::string &name2); + osd_file::error open(const std::string &name1, const std::string &name2, const std::string &name3); + osd_file::error open(const std::string &name1, const std::string &name2, const std::string &name3, const std::string &name4); + osd_file::error open(const std::string &name, UINT32 crc); + osd_file::error open(const std::string &name1, const std::string &name2, UINT32 crc); + osd_file::error open(const std::string &name1, const std::string &name2, const std::string &name3, UINT32 crc); + osd_file::error open(const std::string &name1, const std::string &name2, const std::string &name3, const std::string &name4, UINT32 crc); osd_file::error open_next(); osd_file::error open_ram(const void *data, UINT32 length); void close(); diff --git a/src/emu/romload.cpp b/src/emu/romload.cpp index 7a4d420f205..3ab732770f4 100644 --- a/src/emu/romload.cpp +++ b/src/emu/romload.cpp @@ -1113,7 +1113,7 @@ chd_error rom_load_manager::open_disk_diff(emu_options &options, const rom_entry /* try to open the diff */ LOG(("Opening differencing image file: %s\n", fname.c_str())); emu_file diff_file(options.diff_directory(), OPEN_FLAG_READ | OPEN_FLAG_WRITE); - osd_file::error filerr = diff_file.open(fname.c_str()); + osd_file::error filerr = diff_file.open(fname); if (filerr == osd_file::error::NONE) { std::string fullpath(diff_file.fullpath()); @@ -1126,7 +1126,7 @@ chd_error rom_load_manager::open_disk_diff(emu_options &options, const rom_entry /* didn't work; try creating it instead */ LOG(("Creating differencing image: %s\n", fname.c_str())); diff_file.set_openflags(OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS); - filerr = diff_file.open(fname.c_str()); + filerr = diff_file.open(fname); if (filerr == osd_file::error::NONE) { std::string fullpath(diff_file.fullpath());