Converted more stuff in diimage to use std::string instead of 'const char *'

This commit is contained in:
Nathan Woods 2016-08-01 20:24:06 -04:00
parent 062017977d
commit a7b00e3f6d
4 changed files with 12 additions and 12 deletions

View File

@ -340,18 +340,18 @@ void device_image_interface::message(const char *format, ...)
// actually exists // actually exists
//------------------------------------------------- //-------------------------------------------------
bool device_image_interface::try_change_working_directory(const char *subdir) bool device_image_interface::try_change_working_directory(const std::string &subdir)
{ {
const osd::directory::entry *entry; const osd::directory::entry *entry;
bool success = false; bool success = false;
bool done = false; bool done = false;
auto directory = osd::directory::open(m_working_directory.c_str()); auto directory = osd::directory::open(m_working_directory);
if (directory) if (directory)
{ {
while (!done && (entry = directory->read()) != nullptr) while (!done && (entry = directory->read()) != nullptr)
{ {
if (!core_stricmp(subdir, entry->name)) if (!core_stricmp(subdir.c_str(), entry->name))
{ {
done = true; done = true;
success = entry->type == osd::directory::entry::entry_type::DIR; success = entry->type == osd::directory::entry::entry_type::DIR;
@ -714,7 +714,7 @@ image_error_t device_image_interface::load_image_by_path(UINT32 open_flags, cons
// reopen_for_write // reopen_for_write
//------------------------------------------------- //-------------------------------------------------
int device_image_interface::reopen_for_write(const char *path) int device_image_interface::reopen_for_write(const std::string &path)
{ {
m_file.reset(); m_file.reset();
@ -1164,7 +1164,7 @@ image_init_result device_image_interface::finish_load()
// create - create a image // create - create a image
//------------------------------------------------- //-------------------------------------------------
image_init_result device_image_interface::create(const char *path, const image_device_format *create_format, util::option_resolution *create_args) image_init_result device_image_interface::create(const std::string &path, const image_device_format *create_format, util::option_resolution *create_args)
{ {
int format_index = 0; int format_index = 0;
int cnt = 0; int cnt = 0;

View File

@ -236,9 +236,9 @@ public:
bool open_image_file(emu_options &options); bool open_image_file(emu_options &options);
image_init_result finish_load(); image_init_result finish_load();
void unload(); void unload();
image_init_result create(const char *path, const image_device_format *create_format, util::option_resolution *create_args); image_init_result create(const std::string &path, const image_device_format *create_format, util::option_resolution *create_args);
bool load_software(software_list_device &swlist, const char *swname, const rom_entry *entry); bool load_software(software_list_device &swlist, const char *swname, const rom_entry *entry);
int reopen_for_write(const char *path); int reopen_for_write(const std::string &path);
static void software_name_split(const char *swlist_swname, std::string &swlist_name, std::string &swname, std::string &swpart); static void software_name_split(const char *swlist_swname, std::string &swlist_name, std::string &swname, std::string &swpart);
static void static_set_user_loadable(device_t &device, bool user_loadable) { static void static_set_user_loadable(device_t &device, bool user_loadable) {
@ -267,7 +267,7 @@ protected:
void check_for_file() const { assert_always(m_file, "Illegal operation on unmounted image"); } void check_for_file() const { assert_always(m_file, "Illegal operation on unmounted image"); }
void setup_working_directory(); void setup_working_directory();
bool try_change_working_directory(const char *subdir); bool try_change_working_directory(const std::string &subdir);
void run_hash(void (*partialhash)(util::hash_collection &, const unsigned char *, unsigned long, const char *), util::hash_collection &hashes, const char *types); void run_hash(void (*partialhash)(util::hash_collection &, const unsigned char *, unsigned long, const char *), util::hash_collection &hashes, const char *types);
void image_checkhash(); void image_checkhash();

View File

@ -42,7 +42,7 @@ void menu_control_floppy_image::do_load_create()
{ {
floppy_image_device *fd = static_cast<floppy_image_device *>(&m_image); floppy_image_device *fd = static_cast<floppy_image_device *>(&m_image);
if(input_filename.compare("")==0) { if(input_filename.compare("")==0) {
image_init_result err = fd->create(output_filename.c_str(), nullptr, nullptr); image_init_result err = fd->create(output_filename, nullptr, nullptr);
if (err != image_init_result::PASS) { if (err != image_init_result::PASS) {
machine().popmessage("Error: %s", fd->error()); machine().popmessage("Error: %s", fd->error());
return; return;
@ -51,7 +51,7 @@ void menu_control_floppy_image::do_load_create()
} else { } else {
image_init_result err = fd->load(input_filename); image_init_result err = fd->load(input_filename);
if ((err == image_init_result::PASS) && (output_filename.compare("") != 0)) if ((err == image_init_result::PASS) && (output_filename.compare("") != 0))
err = fd->reopen_for_write(output_filename.c_str()) ? image_init_result::FAIL : image_init_result::PASS; err = fd->reopen_for_write(output_filename) ? image_init_result::FAIL : image_init_result::PASS;
if (err != image_init_result::PASS) { if (err != image_init_result::PASS) {
machine().popmessage("Error: %s", fd->error()); machine().popmessage("Error: %s", fd->error());
return; return;

View File

@ -324,8 +324,8 @@ void menu_control_device_image::handle()
break; break;
case DO_CREATE: { case DO_CREATE: {
auto path = util::zippath_combine(m_current_directory.c_str(), m_current_file.c_str()); auto path = util::zippath_combine(m_current_directory, m_current_file);
image_init_result err = m_image.create(path.c_str(), nullptr, nullptr); image_init_result err = m_image.create(path, nullptr, nullptr);
if (err != image_init_result::PASS) if (err != image_init_result::PASS)
machine().popmessage("Error: %s", m_image.error()); machine().popmessage("Error: %s", m_image.error());
stack_pop(); stack_pop();