summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine
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/mame/machine
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/mame/machine')
-rw-r--r--src/mame/machine/amstrad.cpp4
-rw-r--r--src/mame/machine/electron.cpp2
-rw-r--r--src/mame/machine/gamecom.cpp2
-rw-r--r--src/mame/machine/m1comm.cpp10
-rw-r--r--src/mame/machine/m2comm.cpp10
-rw-r--r--src/mame/machine/mbee.cpp8
-rw-r--r--src/mame/machine/mtx.cpp12
-rw-r--r--src/mame/machine/s32comm.cpp10
-rw-r--r--src/mame/machine/sorcerer.cpp2
-rw-r--r--src/mame/machine/thomson.cpp8
-rw-r--r--src/mame/machine/vtech2.cpp2
-rw-r--r--src/mame/machine/z80bin.cpp8
12 files changed, 39 insertions, 39 deletions
diff --git a/src/mame/machine/amstrad.cpp b/src/mame/machine/amstrad.cpp
index c8b37acd746..f32b13830c1 100644
--- a/src/mame/machine/amstrad.cpp
+++ b/src/mame/machine/amstrad.cpp
@@ -3315,7 +3315,7 @@ DEVICE_IMAGE_LOAD_MEMBER(amstrad_state::amstrad_plus_cartridge)
logerror("IMG: raw CPC+ cartridge file\n");
if (size % 0x4000)
{
- image.seterror(IMAGE_ERROR_UNSPECIFIED, "Attempt to load a raw binary with some block smaller than 16kB in size");
+ image.seterror(image_error::INVALIDIMAGE, "Attempt to load a raw binary with some block smaller than 16kB in size");
return image_init_result::FAIL;
}
else
@@ -3346,7 +3346,7 @@ DEVICE_IMAGE_LOAD_MEMBER(amstrad_state::amstrad_plus_cartridge)
// Is RIFF format (*.cpr)
if (strncmp((char*)(header + 8), "AMS!", 4) != 0)
{
- image.seterror(IMAGE_ERROR_UNSPECIFIED, "Not an Amstrad CPC cartridge image (despite RIFF header)");
+ image.seterror(image_error::INVALIDIMAGE, "Not an Amstrad CPC cartridge image (despite RIFF header)");
return image_init_result::FAIL;
}
diff --git a/src/mame/machine/electron.cpp b/src/mame/machine/electron.cpp
index ac6b9df4dc4..464f4f7a0da 100644
--- a/src/mame/machine/electron.cpp
+++ b/src/mame/machine/electron.cpp
@@ -654,7 +654,7 @@ image_init_result electronsp_state::load_rom(device_image_interface &image, gene
// socket accepts 8K and 16K ROM only
if (size != 0x2000 && size != 0x4000)
{
- image.seterror(IMAGE_ERROR_UNSPECIFIED, "Invalid size: Only 8K/16K is supported");
+ image.seterror(image_error::INVALIDIMAGE, "Invalid size: Only 8K/16K is supported");
return image_init_result::FAIL;
}
diff --git a/src/mame/machine/gamecom.cpp b/src/mame/machine/gamecom.cpp
index 94ce240f443..727f4f8e8ab 100644
--- a/src/mame/machine/gamecom.cpp
+++ b/src/mame/machine/gamecom.cpp
@@ -627,7 +627,7 @@ image_init_result gamecom_state::common_load(device_image_interface &image, gene
if (size != 0x008000 && size != 0x040000 && size != 0x080000
&& size != 0x100000 && size != 0x1c0000 && size != 0x200000)
{
- image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
+ image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size");
return image_init_result::FAIL;
}
diff --git a/src/mame/machine/m1comm.cpp b/src/mame/machine/m1comm.cpp
index e43d5251845..64e763e41f7 100644
--- a/src/mame/machine/m1comm.cpp
+++ b/src/mame/machine/m1comm.cpp
@@ -560,7 +560,7 @@ int m1comm_device::read_frame(int dataSize)
// try to read a message
std::uint32_t recv = 0;
- osd_file::error filerr = m_line_rx->read(m_buffer0, 0, dataSize, recv);
+ std::error_condition filerr = m_line_rx->read(m_buffer0, 0, dataSize, recv);
if (recv > 0)
{
// check if message complete
@@ -581,14 +581,14 @@ int m1comm_device::read_frame(int dataSize)
togo -= recv;
offset += recv;
}
- else if (filerr == osd_file::error::NONE && recv == 0)
+ else if (!filerr && recv == 0)
{
togo = 0;
}
}
}
}
- else if (filerr == osd_file::error::NONE && recv == 0)
+ else if (!filerr && recv == 0)
{
if (m_linkalive == 0x01)
{
@@ -619,11 +619,11 @@ void m1comm_device::send_frame(int dataSize){
if (!m_line_tx)
return;
- osd_file::error filerr;
+ std::error_condition filerr;
std::uint32_t written;
filerr = m_line_tx->write(&m_buffer0, 0, dataSize, written);
- if (filerr != osd_file::error::NONE)
+ if (filerr)
{
if (m_linkalive == 0x01)
{
diff --git a/src/mame/machine/m2comm.cpp b/src/mame/machine/m2comm.cpp
index 4008cd9fd3f..dd25325f6f6 100644
--- a/src/mame/machine/m2comm.cpp
+++ b/src/mame/machine/m2comm.cpp
@@ -632,7 +632,7 @@ int m2comm_device::read_frame(int dataSize)
// try to read a message
std::uint32_t recv = 0;
- osd_file::error filerr = m_line_rx->read(m_buffer0, 0, dataSize, recv);
+ std::error_condition filerr = m_line_rx->read(m_buffer0, 0, dataSize, recv);
if (recv > 0)
{
// check if message complete
@@ -653,14 +653,14 @@ int m2comm_device::read_frame(int dataSize)
togo -= recv;
offset += recv;
}
- else if (filerr == osd_file::error::NONE && recv == 0)
+ else if (!filerr && recv == 0)
{
togo = 0;
}
}
}
}
- else if (filerr == osd_file::error::NONE && recv == 0)
+ else if (!filerr && recv == 0)
{
if (m_linkalive == 0x01)
{
@@ -687,11 +687,11 @@ void m2comm_device::send_frame(int dataSize){
if (!m_line_tx)
return;
- osd_file::error filerr;
+ std::error_condition filerr;
std::uint32_t written;
filerr = m_line_tx->write(&m_buffer0, 0, dataSize, written);
- if (filerr != osd_file::error::NONE)
+ if (filerr)
{
if (m_linkalive == 0x01)
{
diff --git a/src/mame/machine/mbee.cpp b/src/mame/machine/mbee.cpp
index a70c470c445..c6a9ec55763 100644
--- a/src/mame/machine/mbee.cpp
+++ b/src/mame/machine/mbee.cpp
@@ -731,7 +731,7 @@ image_init_result mbee_state::load_cart(device_image_interface &image, generic_s
// "mbp" roms
if ((size == 0) || (size > 0x4000))
{
- image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported ROM size");
+ image.seterror(image_error::INVALIDIMAGE, "Unsupported ROM size");
return image_init_result::FAIL;
}
@@ -744,7 +744,7 @@ image_init_result mbee_state::load_cart(device_image_interface &image, generic_s
logerror ("Rom header = %02X %02X %02X\n", slot->read_rom(0), slot->read_rom(1), slot->read_rom(2));
if ((slot->read_rom(0) != 0xc3) || ((slot->read_rom(2) & 0xe0) != 0xc0))
{
- image.seterror(IMAGE_ERROR_UNSPECIFIED, "Not a PAK rom");
+ image.seterror(image_error::INVALIDIMAGE, "Not a PAK rom");
slot->call_unload();
return image_init_result::FAIL;
}
@@ -754,7 +754,7 @@ image_init_result mbee_state::load_cart(device_image_interface &image, generic_s
// "mbn" roms
if ((size == 0) || (size > 0x2000))
{
- image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported ROM size");
+ image.seterror(image_error::INVALIDIMAGE, "Unsupported ROM size");
return image_init_result::FAIL;
}
m_pak_extended[pak_index] = (size > 0x1000) ? true : false;
@@ -768,7 +768,7 @@ image_init_result mbee_state::load_cart(device_image_interface &image, generic_s
{
if ((slot->read_rom(0) != 0xc3) || ((slot->read_rom(2) & 0xf0) != 0xe0))
{
- image.seterror(IMAGE_ERROR_UNSPECIFIED, "Not a NET rom");
+ image.seterror(image_error::INVALIDIMAGE, "Not a NET rom");
slot->call_unload();
return image_init_result::FAIL;
}
diff --git a/src/mame/machine/mtx.cpp b/src/mame/machine/mtx.cpp
index 8c0c086aab0..3cccaa3d7bf 100644
--- a/src/mame/machine/mtx.cpp
+++ b/src/mame/machine/mtx.cpp
@@ -397,7 +397,7 @@ DEVICE_IMAGE_LOAD_MEMBER( mtx_state::extrom_load )
if (size > 0x80000)
{
- image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported rom size");
+ image.seterror(image_error::INVALIDIMAGE, "Unsupported rom size");
return image_init_result::FAIL;
}
@@ -417,7 +417,7 @@ DEVICE_IMAGE_LOAD_MEMBER( mtx_state::rompak_load )
if (size > 0x2000)
{
- image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
+ image.seterror(image_error::INVALIDIMAGE, "Unsupported cartridge size");
return image_init_result::FAIL;
}
@@ -441,7 +441,7 @@ SNAPSHOT_LOAD_MEMBER(mtx_state::snapshot_cb)
// verify first byte
if (data[0] != 0xff)
{
- image.seterror(IMAGE_ERROR_INVALIDIMAGE, nullptr);
+ image.seterror(image_error::INVALIDIMAGE, nullptr);
return image_init_result::FAIL;
}
@@ -488,7 +488,7 @@ QUICKLOAD_LOAD_MEMBER(mtx_state::quickload_cb)
if (image.length() < 4)
{
- image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short");
+ image.seterror(image_error::INVALIDIMAGE, "File too short");
return image_init_result::FAIL;
}
@@ -497,13 +497,13 @@ QUICKLOAD_LOAD_MEMBER(mtx_state::quickload_cb)
if (image.length() < code_length)
{
- image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File too short");
+ image.seterror(image_error::INVALIDIMAGE, "File too short");
return image_init_result::FAIL;
}
if (code_base < 0x4000 || (code_base + code_length) >= 0x10000)
{
- image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Invalid code base and length");
+ image.seterror(image_error::INVALIDIMAGE, "Invalid code base and length");
return image_init_result::FAIL;
}
diff --git a/src/mame/machine/s32comm.cpp b/src/mame/machine/s32comm.cpp
index b53448b46d3..420b7d54471 100644
--- a/src/mame/machine/s32comm.cpp
+++ b/src/mame/machine/s32comm.cpp
@@ -266,7 +266,7 @@ int s32comm_device::read_frame(int dataSize)
// try to read a message
std::uint32_t recv = 0;
- osd_file::error filerr = m_line_rx->read(m_buffer0, 0, dataSize, recv);
+ std::error_condition filerr = m_line_rx->read(m_buffer0, 0, dataSize, recv);
if (recv > 0)
{
// check if message complete
@@ -287,14 +287,14 @@ int s32comm_device::read_frame(int dataSize)
togo -= recv;
offset += recv;
}
- else if (filerr == osd_file::error::NONE && recv == 0)
+ else if (!filerr && recv == 0)
{
togo = 0;
}
}
}
}
- else if (filerr == osd_file::error::NONE && recv == 0)
+ else if (!filerr && recv == 0)
{
if (m_linkalive == 0x01)
{
@@ -322,11 +322,11 @@ void s32comm_device::send_frame(int dataSize){
if (!m_line_tx)
return;
- osd_file::error filerr;
+ std::error_condition filerr;
std::uint32_t written;
filerr = m_line_tx->write(&m_buffer0, 0, dataSize, written);
- if (filerr != osd_file::error::NONE)
+ if (filerr)
{
if (m_linkalive == 0x01)
{
diff --git a/src/mame/machine/sorcerer.cpp b/src/mame/machine/sorcerer.cpp
index d4eac2ac17d..84a696c1040 100644
--- a/src/mame/machine/sorcerer.cpp
+++ b/src/mame/machine/sorcerer.cpp
@@ -600,7 +600,7 @@ QUICKLOAD_LOAD_MEMBER(sorcerer_state::quickload_cb)
// check size
if (image.length() != 0x1001c)
{
- image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Snapshot must be 65564 bytes");
+ image.seterror(image_error::INVALIDIMAGE, "Snapshot must be 65564 bytes");
image.message("Snapshot must be 65564 bytes");
return image_init_result::FAIL;
}
diff --git a/src/mame/machine/thomson.cpp b/src/mame/machine/thomson.cpp
index 16afac21ceb..f8201ded8da 100644
--- a/src/mame/machine/thomson.cpp
+++ b/src/mame/machine/thomson.cpp
@@ -281,7 +281,7 @@ DEVICE_IMAGE_LOAD_MEMBER( thomson_state::to7_cartridge )
m_thom_cart_nb_banks = 4;
else
{
- image.seterror(IMAGE_ERROR_UNSUPPORTED, string_format("Invalid cartridge size %u", size).c_str());
+ image.seterror(image_error::INVALIDIMAGE, string_format("Invalid cartridge size %u", size).c_str());
return image_init_result::FAIL;
}
@@ -289,7 +289,7 @@ DEVICE_IMAGE_LOAD_MEMBER( thomson_state::to7_cartridge )
{
if ( image.fread( pos, size ) != size )
{
- image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Read error");
+ image.seterror(image_error::INVALIDIMAGE, "Read error");
return image_init_result::FAIL;
}
}
@@ -1389,7 +1389,7 @@ DEVICE_IMAGE_LOAD_MEMBER( thomson_state::mo5_cartridge )
m_thom_cart_nb_banks = 4;
else
{
- image.seterror(IMAGE_ERROR_UNSUPPORTED, string_format("Invalid cartridge size %d", size).c_str());
+ image.seterror(image_error::INVALIDIMAGE, string_format("Invalid cartridge size %d", size).c_str());
return image_init_result::FAIL;
}
@@ -1397,7 +1397,7 @@ DEVICE_IMAGE_LOAD_MEMBER( thomson_state::mo5_cartridge )
{
if ( image.fread(pos, size ) != size )
{
- image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Read error");
+ image.seterror(image_error::INVALIDIMAGE, "Read error");
return image_init_result::FAIL;
}
}
diff --git a/src/mame/machine/vtech2.cpp b/src/mame/machine/vtech2.cpp
index 3ac1e62ce3f..0e8a2bea126 100644
--- a/src/mame/machine/vtech2.cpp
+++ b/src/mame/machine/vtech2.cpp
@@ -54,7 +54,7 @@ DEVICE_IMAGE_LOAD_MEMBER( vtech2_state::cart_load )
if (m_cart_size > 0x10000)
{
- image.seterror(IMAGE_ERROR_UNSPECIFIED, "Cartridge bigger than 64k");
+ image.seterror(image_error::INVALIDIMAGE, "Cartridge bigger than 64k");
m_cart_size = 0;
return image_init_result::FAIL;
}
diff --git a/src/mame/machine/z80bin.cpp b/src/mame/machine/z80bin.cpp
index ba24d545d1f..c14cf196819 100644
--- a/src/mame/machine/z80bin.cpp
+++ b/src/mame/machine/z80bin.cpp
@@ -23,7 +23,7 @@ image_init_result z80bin_load_file(device_image_interface &image, address_space
{
if (ch == EOF)
{
- image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Unexpected EOF while getting file name");
+ image.seterror(image_error::INVALIDIMAGE, "Unexpected EOF while getting file name");
image.message(" Unexpected EOF while getting file name");
return image_init_result::FAIL;
}
@@ -32,7 +32,7 @@ image_init_result z80bin_load_file(device_image_interface &image, address_space
{
if (i >= (std::size(pgmname) - 1))
{
- image.seterror(IMAGE_ERROR_INVALIDIMAGE, "File name too long");
+ image.seterror(image_error::INVALIDIMAGE, "File name too long");
image.message(" File name too long");
return image_init_result::FAIL;
}
@@ -46,7 +46,7 @@ image_init_result z80bin_load_file(device_image_interface &image, address_space
if (image.fread(args, sizeof(args)) != sizeof(args))
{
- image.seterror(IMAGE_ERROR_INVALIDIMAGE, "Unexpected EOF while getting file size");
+ image.seterror(image_error::INVALIDIMAGE, "Unexpected EOF while getting file size");
image.message(" Unexpected EOF while getting file size");
return image_init_result::FAIL;
}
@@ -66,7 +66,7 @@ image_init_result z80bin_load_file(device_image_interface &image, address_space
if (image.fread(&data, 1) != 1)
{
snprintf(message, std::size(message), "%s: Unexpected EOF while writing byte to %04X", pgmname, (unsigned) j);
- image.seterror(IMAGE_ERROR_INVALIDIMAGE, message);
+ image.seterror(image_error::INVALIDIMAGE, message);
image.message("%s: Unexpected EOF while writing byte to %04X", pgmname, (unsigned) j);
return image_init_result::FAIL;
}