summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend/mame/ui
diff options
context:
space:
mode:
author Vas Crabb <cuavas@users.noreply.github.com>2021-08-22 09:06:15 +1000
committer GitHub <noreply@github.com>2021-08-22 09:06:15 +1000
commite8bbea1fc6e94e14768509d322f6c624403ffb36 (patch)
tree74dd1606a900d83de8aecff17a6737af4113308d /src/frontend/mame/ui
parente319bde5fc3696d7f48f62b15b6366c4377fe5d1 (diff)
formats, osd, util: Started refactoring file I/O stuff. (#8456)
Added more modern generic I/O interfaces with implementation backed by stdio, osd_file and core_file, replacing io_generic. Also replaced core_file's build-in zlib compression with a filter. unzip.cpp, un7z.cpp: Added option to supply abstract I/O interface rather than filename. Converted osd_file, core_file, archive_file, chd_file and device_image_interface to use std::error_condition rather than their own error enums. Allow mounting TI-99 RPK from inside archives.
Diffstat (limited to 'src/frontend/mame/ui')
-rw-r--r--src/frontend/mame/ui/auditmenu.cpp2
-rw-r--r--src/frontend/mame/ui/filesel.cpp12
-rw-r--r--src/frontend/mame/ui/floppycntrl.cpp5
-rw-r--r--src/frontend/mame/ui/imgcntrl.cpp2
-rw-r--r--src/frontend/mame/ui/inifile.cpp8
-rw-r--r--src/frontend/mame/ui/menu.cpp4
-rw-r--r--src/frontend/mame/ui/miscmenu.cpp18
-rw-r--r--src/frontend/mame/ui/optsmenu.cpp2
-rw-r--r--src/frontend/mame/ui/selgame.cpp12
-rw-r--r--src/frontend/mame/ui/selmenu.cpp30
-rw-r--r--src/frontend/mame/ui/selsoft.cpp8
-rw-r--r--src/frontend/mame/ui/state.cpp10
-rw-r--r--src/frontend/mame/ui/ui.cpp13
13 files changed, 62 insertions, 64 deletions
diff --git a/src/frontend/mame/ui/auditmenu.cpp b/src/frontend/mame/ui/auditmenu.cpp
index 9cadb5b5d97..66c1aab0597 100644
--- a/src/frontend/mame/ui/auditmenu.cpp
+++ b/src/frontend/mame/ui/auditmenu.cpp
@@ -229,7 +229,7 @@ void menu_audit::save_available_machines()
{
// attempt to open the output file
emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
- if (file.open(std::string(emulator_info::get_configname()) + "_avail.ini") == osd_file::error::NONE)
+ if (!file.open(std::string(emulator_info::get_configname()) + "_avail.ini"))
{
// generate header
file.printf("#\n%s%s\n#\n\n", UI_VERSION_TAG, emulator_info::get_bare_build_version());
diff --git a/src/frontend/mame/ui/filesel.cpp b/src/frontend/mame/ui/filesel.cpp
index b722afab60d..bc5c5abbd12 100644
--- a/src/frontend/mame/ui/filesel.cpp
+++ b/src/frontend/mame/ui/filesel.cpp
@@ -316,8 +316,8 @@ void menu_file_selector::select_item(const file_selector_entry &entry)
{
// drive/directory - first check the path
util::zippath_directory::ptr dir;
- osd_file::error const err = util::zippath_directory::open(entry.fullpath, dir);
- if (err != osd_file::error::NONE)
+ std::error_condition const err = util::zippath_directory::open(entry.fullpath, dir);
+ if (err)
{
// this path is problematic; present the user with an error and bail
ui().popup_time(1, _("Error accessing %s"), entry.fullpath);
@@ -399,7 +399,7 @@ void menu_file_selector::populate(float &customtop, float &custombottom)
// open the directory
util::zippath_directory::ptr directory;
- osd_file::error const err = util::zippath_directory::open(m_current_directory, directory);
+ std::error_condition const err = util::zippath_directory::open(m_current_directory, directory);
// add the "[empty slot]" entry if available
if (m_has_empty)
@@ -421,9 +421,11 @@ void menu_file_selector::populate(float &customtop, float &custombottom)
std::size_t const first = m_entrylist.size() + 1;
// build the menu for each item
- if (osd_file::error::NONE != err)
+ if (err)
{
- osd_printf_verbose("menu_file_selector::populate: error opening directory '%s' (%d)\n", m_current_directory, int(err));
+ osd_printf_verbose(
+ "menu_file_selector::populate: error opening directory '%s' (%s:%d %s)\n",
+ m_current_directory, err.category().name(), err.value(), err.message());
}
else
{
diff --git a/src/frontend/mame/ui/floppycntrl.cpp b/src/frontend/mame/ui/floppycntrl.cpp
index 0cfc8ac2333..2f1cc9e0192 100644
--- a/src/frontend/mame/ui/floppycntrl.cpp
+++ b/src/frontend/mame/ui/floppycntrl.cpp
@@ -79,12 +79,11 @@ void menu_control_floppy_image::hook_load(const std::string &filename)
bool can_in_place = input_format->supports_save();
if(can_in_place) {
- osd_file::error filerr;
std::string tmp_path;
util::core_file::ptr tmp_file;
// attempt to open the file for writing but *without* create
- filerr = util::zippath_fopen(filename, OPEN_FLAG_READ | OPEN_FLAG_WRITE, tmp_file, tmp_path);
- if(filerr == osd_file::error::NONE)
+ std::error_condition const filerr = util::zippath_fopen(filename, OPEN_FLAG_READ | OPEN_FLAG_WRITE, tmp_file, tmp_path);
+ if(!filerr)
tmp_file.reset();
else
can_in_place = false;
diff --git a/src/frontend/mame/ui/imgcntrl.cpp b/src/frontend/mame/ui/imgcntrl.cpp
index 33a71b7354a..43f40603479 100644
--- a/src/frontend/mame/ui/imgcntrl.cpp
+++ b/src/frontend/mame/ui/imgcntrl.cpp
@@ -85,7 +85,7 @@ menu_control_device_image::menu_control_device_image(mame_ui_manager &mui, rende
// check to see if the path exists; if not then set to current directory
util::zippath_directory::ptr dir;
- if (util::zippath_directory::open(m_current_directory, dir) != osd_file::error::NONE)
+ if (util::zippath_directory::open(m_current_directory, dir))
osd_get_full_path(m_current_directory, ".");
}
}
diff --git a/src/frontend/mame/ui/inifile.cpp b/src/frontend/mame/ui/inifile.cpp
index f1e0346769a..000ea922a4a 100644
--- a/src/frontend/mame/ui/inifile.cpp
+++ b/src/frontend/mame/ui/inifile.cpp
@@ -45,7 +45,7 @@ inifile_manager::inifile_manager(ui_options &options)
if (core_filename_ends_with(name, ".ini"))
{
emu_file file(m_options.categoryini_path(), OPEN_FLAG_READ);
- if (file.open(name) == osd_file::error::NONE)
+ if (!file.open(name))
{
init_category(std::move(name), file);
file.close();
@@ -63,7 +63,7 @@ void inifile_manager::load_ini_category(size_t file, size_t category, std::unord
{
std::string const &filename(m_ini_index[file].first);
emu_file fp(m_options.categoryini_path(), OPEN_FLAG_READ);
- if (fp.open(filename) != osd_file::error::NONE)
+ if (fp.open(filename))
{
osd_printf_error("Failed to open category file %s for reading\n", filename);
return;
@@ -216,7 +216,7 @@ favorite_manager::favorite_manager(ui_options &options)
, m_need_sort(true)
{
emu_file file(m_options.ui_path(), OPEN_FLAG_READ);
- if (file.open(FAVORITE_FILENAME) == osd_file::error::NONE)
+ if (!file.open(FAVORITE_FILENAME))
{
char readbuf[1024];
file.gets(readbuf, 1024);
@@ -537,7 +537,7 @@ void favorite_manager::save_favorites()
{
// attempt to open the output file
emu_file file(m_options.ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
- if (file.open(FAVORITE_FILENAME) == osd_file::error::NONE)
+ if (!file.open(FAVORITE_FILENAME))
{
if (m_favorites.empty())
{
diff --git a/src/frontend/mame/ui/menu.cpp b/src/frontend/mame/ui/menu.cpp
index 8eb1eab47c9..923a0fae6df 100644
--- a/src/frontend/mame/ui/menu.cpp
+++ b/src/frontend/mame/ui/menu.cpp
@@ -92,13 +92,13 @@ menu::global_state::global_state(running_machine &machine, ui_options const &opt
{
m_bgrnd_bitmap = std::make_unique<bitmap_argb32>(0, 0);
emu_file backgroundfile(".", OPEN_FLAG_READ);
- if (backgroundfile.open("background.jpg") == osd_file::error::NONE)
+ if (!backgroundfile.open("background.jpg"))
{
render_load_jpeg(*m_bgrnd_bitmap, backgroundfile);
backgroundfile.close();
}
- if (!m_bgrnd_bitmap->valid() && (backgroundfile.open("background.png") == osd_file::error::NONE))
+ if (!m_bgrnd_bitmap->valid() && !backgroundfile.open("background.png"))
{
render_load_png(*m_bgrnd_bitmap, backgroundfile);
backgroundfile.close();
diff --git a/src/frontend/mame/ui/miscmenu.cpp b/src/frontend/mame/ui/miscmenu.cpp
index bf1754481dc..da7989e6e3b 100644
--- a/src/frontend/mame/ui/miscmenu.cpp
+++ b/src/frontend/mame/ui/miscmenu.cpp
@@ -599,11 +599,11 @@ void menu_export::handle()
{
std::string filename("exported");
emu_file infile(ui().options().ui_path(), OPEN_FLAG_READ);
- if (infile.open(filename + ".xml") == osd_file::error::NONE)
+ if (!infile.open(filename + ".xml"))
for (int seq = 0; ; ++seq)
{
const std::string seqtext = string_format("%s_%04d", filename, seq);
- if (infile.open(seqtext + ".xml") != osd_file::error::NONE)
+ if (infile.open(seqtext + ".xml"))
{
filename = seqtext;
break;
@@ -612,7 +612,7 @@ void menu_export::handle()
// attempt to open the output file
emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
- if (file.open(filename + ".xml") == osd_file::error::NONE)
+ if (!file.open(filename + ".xml"))
{
const std::string fullpath(file.fullpath());
file.close();
@@ -644,11 +644,11 @@ void menu_export::handle()
{
std::string filename("exported");
emu_file infile(ui().options().ui_path(), OPEN_FLAG_READ);
- if (infile.open(filename + ".txt") == osd_file::error::NONE)
+ if (!infile.open(filename + ".txt"))
for (int seq = 0; ; ++seq)
{
const std::string seqtext = string_format("%s_%04d", filename, seq);
- if (infile.open(seqtext + ".txt") != osd_file::error::NONE)
+ if (infile.open(seqtext + ".txt"))
{
filename = seqtext;
break;
@@ -657,7 +657,7 @@ void menu_export::handle()
// attempt to open the output file
emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
- if (file.open(filename + ".txt") == osd_file::error::NONE)
+ if (!file.open(filename + ".txt"))
{
// print the header
std::ostringstream buffer;
@@ -754,8 +754,8 @@ void menu_machine_configure::handle()
{
const std::string filename(m_drv.name);
emu_file file(machine().options().ini_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE);
- osd_file::error filerr = file.open(filename + ".ini");
- if (filerr == osd_file::error::NONE)
+ std::error_condition const filerr = file.open(filename + ".ini");
+ if (!filerr)
{
std::string inistring = m_opts.output_ini();
file.puts(inistring);
@@ -891,7 +891,7 @@ menu_plugins_configure::menu_plugins_configure(mame_ui_manager &mui, render_cont
menu_plugins_configure::~menu_plugins_configure()
{
emu_file file_plugin(machine().options().ini_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
- if (file_plugin.open("plugin.ini") != osd_file::error::NONE)
+ if (file_plugin.open("plugin.ini"))
// Can't throw in a destructor, so let's ignore silently for
// now. We shouldn't write files in a destructor in any case.
//
diff --git a/src/frontend/mame/ui/optsmenu.cpp b/src/frontend/mame/ui/optsmenu.cpp
index 0ceeca25ce2..922bbb5b6fa 100644
--- a/src/frontend/mame/ui/optsmenu.cpp
+++ b/src/frontend/mame/ui/optsmenu.cpp
@@ -265,7 +265,7 @@ void menu_game_options::handle_item_event(event const &menu_event)
if (machine_filter::CUSTOM == filter.get_type())
{
emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
- if (file.open(util::string_format("custom_%s_filter.ini", emulator_info::get_configname())) == osd_file::error::NONE)
+ if (!file.open(util::string_format("custom_%s_filter.ini", emulator_info::get_configname())))
{
filter.save_ini(file, 0);
file.close();
diff --git a/src/frontend/mame/ui/selgame.cpp b/src/frontend/mame/ui/selgame.cpp
index 338f98c42d0..ece205a8ef4 100644
--- a/src/frontend/mame/ui/selgame.cpp
+++ b/src/frontend/mame/ui/selgame.cpp
@@ -266,7 +266,7 @@ menu_select_game::menu_select_game(mame_ui_manager &mui, render_container &conta
}
emu_file file(ui().options().ui_path(), OPEN_FLAG_READ);
- if (file.open_ram(fake_ini.c_str(), fake_ini.size()) == osd_file::error::NONE)
+ if (!file.open_ram(fake_ini.c_str(), fake_ini.size()))
{
m_persistent_data.filter_data().load_ini(file);
file.close();
@@ -1259,12 +1259,12 @@ render_texture *menu_select_game::get_icon_texture(int linenum, void *selectedre
bitmap_argb32 tmp;
emu_file snapfile(std::string(m_icon_paths), OPEN_FLAG_READ);
- if (snapfile.open(std::string(driver->name) + ".ico") == osd_file::error::NONE)
+ if (!snapfile.open(std::string(driver->name) + ".ico"))
{
render_load_ico_highest_detail(snapfile, tmp);
snapfile.close();
}
- if (!tmp.valid() && cloneof && (snapfile.open(std::string(driver->parent) + ".ico") == osd_file::error::NONE))
+ if (!tmp.valid() && cloneof && !snapfile.open(std::string(driver->parent) + ".ico"))
{
render_load_ico_highest_detail(snapfile, tmp);
snapfile.close();
@@ -1309,7 +1309,7 @@ bool menu_select_game::load_available_machines()
{
// try to load available drivers from file
emu_file file(ui().options().ui_path(), OPEN_FLAG_READ);
- if (file.open(std::string(emulator_info::get_configname()) + "_avail.ini") != osd_file::error::NONE)
+ if (file.open(std::string(emulator_info::get_configname()) + "_avail.ini"))
return false;
char rbuf[MAX_CHAR_INFO];
@@ -1361,7 +1361,7 @@ bool menu_select_game::load_available_machines()
void menu_select_game::load_custom_filters()
{
emu_file file(ui().options().ui_path(), OPEN_FLAG_READ);
- if (file.open(util::string_format("custom_%s_filter.ini", emulator_info::get_configname())) == osd_file::error::NONE)
+ if (!file.open(util::string_format("custom_%s_filter.ini", emulator_info::get_configname())))
{
machine_filter::ptr flt(machine_filter::create(file, m_persistent_data.filter_data()));
if (flt)
@@ -1456,7 +1456,7 @@ void menu_select_game::filter_selected()
if (machine_filter::CUSTOM == new_type)
{
emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
- if (file.open(util::string_format("custom_%s_filter.ini", emulator_info::get_configname())) == osd_file::error::NONE)
+ if (!file.open(util::string_format("custom_%s_filter.ini", emulator_info::get_configname())))
{
filter.save_ini(file, 0);
file.close();
diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp
index fb3f7087e27..15c7e1c3364 100644
--- a/src/frontend/mame/ui/selmenu.cpp
+++ b/src/frontend/mame/ui/selmenu.cpp
@@ -36,6 +36,8 @@
#include "uiinput.h"
#include "luaengine.h"
+#include "util/path.h"
+
#include <algorithm>
#include <cmath>
#include <cstring>
@@ -99,19 +101,19 @@ char const *const hover_msg[] = {
void load_image(bitmap_argb32 &bitmap, emu_file &file, std::string const &base)
{
- if (file.open(base + ".png") == osd_file::error::NONE)
+ if (!file.open(base + ".png"))
{
render_load_png(bitmap, file);
file.close();
}
- if (!bitmap.valid() && (file.open(base + ".jpg") == osd_file::error::NONE))
+ if (!bitmap.valid() && !file.open(base + ".jpg"))
{
render_load_jpeg(bitmap, file);
file.close();
}
- if (!bitmap.valid() && (file.open(base + ".bmp") == osd_file::error::NONE))
+ if (!bitmap.valid() && !file.open(base + ".bmp"))
{
render_load_msdib(bitmap, file);
file.close();
@@ -123,7 +125,7 @@ void load_driver_image(bitmap_argb32 &bitmap, emu_file &file, game_driver const
{
// try to load snapshot first from saved "0000.png" file
std::string fullname = driver.name;
- load_image(bitmap, file, fullname + PATH_SEPARATOR + "0000");
+ load_image(bitmap, file, util::path_concat(fullname, "0000"));
// if fail, attempt to load from standard file
if (!bitmap.valid())
@@ -144,7 +146,7 @@ void load_driver_image(bitmap_argb32 &bitmap, emu_file &file, game_driver const
if (isclone)
{
fullname = driver.parent;
- load_image(bitmap, file, fullname + PATH_SEPARATOR + "0000");
+ load_image(bitmap, file, util::path_concat(fullname, "0000"));
if (!bitmap.valid())
load_image(bitmap, file, fullname);
@@ -621,7 +623,7 @@ void menu_select_launch::launch_system(mame_ui_manager &mui, game_driver const &
else
moptions.set_value(OPTION_SOFTWARENAME, util::string_format("%s:%s", swinfo->listname, swinfo->shortname), OPTION_PRIORITY_CMDLINE);
- moptions.set_value(OPTION_SNAPNAME, util::string_format("%s%s%s", swinfo->listname, PATH_SEPARATOR, swinfo->shortname), OPTION_PRIORITY_CMDLINE);
+ moptions.set_value(OPTION_SNAPNAME, util::path_concat(swinfo->listname, swinfo->shortname), OPTION_PRIORITY_CMDLINE);
}
reselect_last::set_software(driver, *swinfo);
}
@@ -1087,11 +1089,7 @@ void menu_select_launch::check_for_icons(char const *listname)
{
// if we're doing a software list, append it to the configured path
if (listname)
- {
- if (!current.empty() && !util::is_directory_separator(current.back()))
- current.append(PATH_SEPARATOR);
- current.append(listname);
- }
+ util::path_append(current, listname);
osd_printf_verbose("Checking for icons in directory %s\n", current);
// open and walk the directory
@@ -1136,11 +1134,7 @@ std::string menu_select_launch::make_icon_paths(char const *listname) const
{
// if we're doing a software list, append it to the configured path
if (listname)
- {
- if (!current.empty() && !util::is_directory_separator(current.back()))
- current.append(PATH_SEPARATOR);
- current.append(listname);
- }
+ util::path_append(current, listname);
// append the configured path
if (!result.empty())
@@ -2286,11 +2280,11 @@ void menu_select_launch::arts_render(float origx1, float origy1, float origx2, f
else
{
// First attempt from name list
- load_image(tmp_bitmap, snapfile, software->listname + PATH_SEPARATOR + software->shortname);
+ load_image(tmp_bitmap, snapfile, util::path_concat(software->listname, software->shortname));
// Second attempt from driver name + part name
if (!tmp_bitmap.valid())
- load_image(tmp_bitmap, snapfile, software->driver->name + software->part + PATH_SEPARATOR + software->shortname);
+ load_image(tmp_bitmap, snapfile, util::path_concat(software->driver->name + software->part, software->shortname));
}
m_cache->set_snapx_software(software);
diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp
index 2ac32cce987..95c02a9d853 100644
--- a/src/frontend/mame/ui/selsoft.cpp
+++ b/src/frontend/mame/ui/selsoft.cpp
@@ -517,7 +517,7 @@ void menu_select_software::load_sw_custom_filters()
{
// attempt to open the output file
emu_file file(ui().options().ui_path(), OPEN_FLAG_READ);
- if (file.open(util::string_format("custom_%s_filter.ini", m_driver.name)) == osd_file::error::NONE)
+ if (!file.open(util::string_format("custom_%s_filter.ini", m_driver.name)))
{
software_filter::ptr flt(software_filter::create(file, m_filter_data));
if (flt)
@@ -593,12 +593,12 @@ render_texture *menu_select_software::get_icon_texture(int linenum, void *select
bitmap_argb32 tmp;
emu_file snapfile(std::string(paths->second), OPEN_FLAG_READ);
- if (snapfile.open(std::string(swinfo->shortname) + ".ico") == osd_file::error::NONE)
+ if (!snapfile.open(std::string(swinfo->shortname) + ".ico"))
{
render_load_ico_highest_detail(snapfile, tmp);
snapfile.close();
}
- if (!tmp.valid() && !swinfo->parentname.empty() && (snapfile.open(std::string(swinfo->parentname) + ".ico") == osd_file::error::NONE))
+ if (!tmp.valid() && !swinfo->parentname.empty() && !snapfile.open(std::string(swinfo->parentname) + ".ico"))
{
render_load_ico_highest_detail(snapfile, tmp);
snapfile.close();
@@ -668,7 +668,7 @@ void menu_select_software::filter_selected()
if (software_filter::CUSTOM == new_type)
{
emu_file file(ui().options().ui_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
- if (file.open(util::string_format("custom_%s_filter.ini", m_driver.name)) == osd_file::error::NONE)
+ if (!file.open(util::string_format("custom_%s_filter.ini", m_driver.name)))
{
filter.save_ini(file, 0);
file.close();
diff --git a/src/frontend/mame/ui/state.cpp b/src/frontend/mame/ui/state.cpp
index 8f911b8f15b..6bb0b9ccdc5 100644
--- a/src/frontend/mame/ui/state.cpp
+++ b/src/frontend/mame/ui/state.cpp
@@ -365,14 +365,16 @@ void menu_load_save_state_base::handle_keys(uint32_t flags, int &iptkey)
machine().options().state_directory(),
machine().get_statename(machine().options().state_name()),
m_confirm_delete->file_name()));
- osd_file::error const err(osd_file::remove(filename));
- if (osd_file::error::NONE != err)
+ std::error_condition const err(osd_file::remove(filename));
+ if (err)
{
osd_printf_error(
- "Error removing file %s for state %s (%d)\n",
+ "Error removing file %s for state %s (%s:%d %s)\n",
filename,
m_confirm_delete->visible_name(),
- std::underlying_type_t<osd_file::error>(err));
+ err.category().name(),
+ err.value(),
+ err.message());
machine().popmessage(_("Error removing saved state file %1$s"), filename);
}
diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp
index 9f176cca141..22404f32364 100644
--- a/src/frontend/mame/ui/ui.cpp
+++ b/src/frontend/mame/ui/ui.cpp
@@ -2136,7 +2136,7 @@ void mame_ui_manager::load_ui_options()
// parse the file
// attempt to open the output file
emu_file file(machine().options().ini_path(), OPEN_FLAG_READ);
- if (file.open("ui.ini") == osd_file::error::NONE)
+ if (!file.open("ui.ini"))
{
try
{
@@ -2157,7 +2157,7 @@ void mame_ui_manager::save_ui_options()
{
// attempt to open the output file
emu_file file(machine().options().ini_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
- if (file.open("ui.ini") == osd_file::error::NONE)
+ if (!file.open("ui.ini"))
{
// generate the updated INI
file.puts(options().output_ini());
@@ -2185,13 +2185,13 @@ void mame_ui_manager::save_main_option()
// attempt to open the main ini file
{
emu_file file(machine().options().ini_path(), OPEN_FLAG_READ);
- if (file.open(std::string(emulator_info::get_configname()) + ".ini") == osd_file::error::NONE)
+ if (!file.open(std::string(emulator_info::get_configname()) + ".ini"))
{
try
{
options.parse_ini_file((util::core_file&)file, OPTION_PRIORITY_MAME_INI, OPTION_PRIORITY_MAME_INI < OPTION_PRIORITY_DRIVER_INI, true);
}
- catch(options_error_exception &)
+ catch (options_error_exception &)
{
osd_printf_error("**Error loading %s.ini**\n", emulator_info::get_configname());
return;
@@ -2215,13 +2215,14 @@ void mame_ui_manager::save_main_option()
// attempt to open the output file
{
emu_file file(machine().options().ini_path(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
- if (file.open(std::string(emulator_info::get_configname()) + ".ini") == osd_file::error::NONE)
+ if (!file.open(std::string(emulator_info::get_configname()) + ".ini"))
{
// generate the updated INI
file.puts(options.output_ini());
file.close();
}
- else {
+ else
+ {
machine().popmessage(_("**Error saving %s.ini**"), emulator_info::get_configname());
return;
}