diff options
author | 2021-08-22 09:06:15 +1000 | |
---|---|---|
committer | 2021-08-22 09:06:15 +1000 | |
commit | e8bbea1fc6e94e14768509d322f6c624403ffb36 (patch) | |
tree | 74dd1606a900d83de8aecff17a6737af4113308d /src/frontend/mame/media_ident.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/frontend/mame/media_ident.cpp')
-rw-r--r-- | src/frontend/mame/media_ident.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/frontend/mame/media_ident.cpp b/src/frontend/mame/media_ident.cpp index 690996145b2..08a7381ad3e 100644 --- a/src/frontend/mame/media_ident.cpp +++ b/src/frontend/mame/media_ident.cpp @@ -134,13 +134,13 @@ void media_identifier::collect_files(std::vector<file_info> &info, char const *p { // first attempt to examine it as a valid zip/7z file util::archive_file::ptr archive; - util::archive_file::error err; + std::error_condition err; if (core_filename_ends_with(path, ".7z")) err = util::archive_file::open_7z(path, archive); else err = util::archive_file::open_zip(path, archive); - if ((util::archive_file::error::NONE == err) && archive) + if (!err && archive) { std::vector<std::uint8_t> data; @@ -158,10 +158,10 @@ void media_identifier::collect_files(std::vector<file_info> &info, char const *p { data.resize(std::size_t(length)); err = archive->decompress(&data[0], std::uint32_t(length)); - if (util::archive_file::error::NONE == err) + if (!err) digest_data(info, curfile.c_str(), &data[0], length); else - osd_printf_error("%s: error decompressing file\n", curfile); + osd_printf_error("%s: error decompressing file (%s:%d %s)\n", curfile, err.category().name(), err.value(), err.message()); } catch (...) { @@ -205,9 +205,9 @@ void media_identifier::digest_file(std::vector<file_info> &info, char const *pat { // attempt to open as a CHD; fail if not chd_file chd; - chd_error const err = chd.open(path); + std::error_condition const err = chd.open(path); m_total++; - if (err != CHDERR_NONE) + if (err) { osd_printf_info("%-20s NOT A CHD\n", core_filename_extract_base(path)); m_nonroms++; @@ -233,7 +233,7 @@ void media_identifier::digest_file(std::vector<file_info> &info, char const *pat // load the file and process if it opens and has a valid length uint32_t length; void *data; - if (osd_file::error::NONE == util::core_file::load(path, &data, length)) + if (!util::core_file::load(path, &data, length)) { jed_data jed; if (JEDERR_NONE == jed_parse(data, length, &jed)) @@ -260,7 +260,7 @@ void media_identifier::digest_file(std::vector<file_info> &info, char const *pat // load the file and process if it opens and has a valid length util::core_file::ptr file; - if ((osd_file::error::NONE == util::core_file::open(path, OPEN_FLAG_READ, file)) && file) + if (!util::core_file::open(path, OPEN_FLAG_READ, file) && file) { util::hash_collection hashes; hashes.begin(util::hash_collection::HASH_TYPES_CRC_SHA1); |