diff options
author | 2021-08-22 09:06:15 +1000 | |
---|---|---|
committer | 2021-08-22 09:06:15 +1000 | |
commit | e8bbea1fc6e94e14768509d322f6c624403ffb36 (patch) | |
tree | 74dd1606a900d83de8aecff17a6737af4113308d /src/emu/rendlay.cpp | |
parent | e319bde5fc3696d7f48f62b15b6366c4377fe5d1 (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/emu/rendlay.cpp')
-rw-r--r-- | src/emu/rendlay.cpp | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/src/emu/rendlay.cpp b/src/emu/rendlay.cpp index 13b2d6e16c1..c3f7a70a2e8 100644 --- a/src/emu/rendlay.cpp +++ b/src/emu/rendlay.cpp @@ -17,10 +17,11 @@ #include "rendutil.h" #include "video/rgbutil.h" -#include "nanosvg.h" -#include "unicode.h" -#include "vecstream.h" -#include "xmlfile.h" +#include "util/nanosvg.h" +#include "util/path.h" +#include "util/unicode.h" +#include "util/vecstream.h" +#include "util/xmlfile.h" #include <cctype> #include <algorithm> @@ -1713,12 +1714,10 @@ private: std::string filename; if (!m_searchpath.empty()) filename = m_dirname; - if (!filename.empty() && !util::is_directory_separator(filename[filename.size() - 1])) - filename.append(PATH_SEPARATOR); - filename.append(m_imagefile); + util::path_append(filename, m_imagefile); LOGMASKED(LOG_IMAGE_LOAD, "Image component attempt to load image file '%s'\n", filename); - osd_file::error const imgerr = file.open(filename); - if (osd_file::error::NONE == imgerr) + std::error_condition const imgerr = file.open(filename); + if (!imgerr) { if (!load_bitmap(file)) { @@ -1729,7 +1728,8 @@ private: } else { - LOGMASKED(LOG_IMAGE_LOAD, "Image component unable to open image file '%s'\n", filename); + LOGMASKED(LOG_IMAGE_LOAD, "Image component unable to open image file '%s' (%s:%d %s)\n", + filename, imgerr.category().name(), imgerr.value(), imgerr.message()); } } else if (!m_data.empty()) @@ -1745,12 +1745,10 @@ private: std::string filename; if (!m_searchpath.empty()) filename = m_dirname; - if (!filename.empty() && !util::is_directory_separator(filename[filename.size() - 1])) - filename.append(PATH_SEPARATOR); - filename.append(m_alphafile); + util::path_append(filename, m_alphafile); LOGMASKED(LOG_IMAGE_LOAD, "Image component attempt to load alpha channel from file '%s'\n", filename); - osd_file::error const alferr = file.open(filename); - if (osd_file::error::NONE == alferr) + std::error_condition const alferr = file.open(filename); + if (!alferr) { // TODO: no way to detect corner case where we had alpha from the image but the alpha PNG makes it entirely opaque if (render_load_png(m_bitmap, file, true)) @@ -1759,7 +1757,8 @@ private: } else { - LOGMASKED(LOG_IMAGE_LOAD, "Image component unable to open alpha channel file '%s'\n", filename); + LOGMASKED(LOG_IMAGE_LOAD, "Image component unable to open alpha channel file '%s' (%s:%d %s)\n", + filename, alferr.category().name(), alferr.value(), alferr.message()); } } else if (m_svg) @@ -1841,8 +1840,8 @@ private: // make a file wrapper for the data and see if it looks like a bitmap util::core_file::ptr file; - osd_file::error const filerr(util::core_file::open_ram(m_data.c_str(), m_data.size(), OPEN_FLAG_READ, file)); - bool const bitmapdata((osd_file::error::NONE == filerr) && file && load_bitmap(*file)); + std::error_condition const filerr(util::core_file::open_ram(m_data.c_str(), m_data.size(), OPEN_FLAG_READ, file)); + bool const bitmapdata(!filerr && file && load_bitmap(*file)); file.reset(); // if it didn't look like a bitmap, see if it looks like it might be XML and hence SVG @@ -3398,12 +3397,10 @@ private: std::string filename; if (!m_searchpath.empty()) filename = m_dirname; - if (!filename.empty() && !util::is_directory_separator(filename[filename.size() - 1])) - filename.append(PATH_SEPARATOR); - filename.append(m_imagefile[number]); + util::path_append(filename, m_imagefile[number]); // load the basic bitmap - if (file.open(filename) == osd_file::error::NONE) + if (!file.open(filename)) render_load_png(m_bitmap[number], file); // if we can't load the bitmap just use text rendering |