summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices
diff options
context:
space:
mode:
author Vas Crabb <cuavas@users.noreply.github.com>2021-10-05 03:34:45 +1100
committer GitHub <noreply@github.com>2021-10-05 03:34:45 +1100
commitaeb9eae87469e67bc6a91caf3840c34c11d959fc (patch)
tree45bffedf374dbce47caca633ad7bda547592e6c9 /src/devices
parent33723892a3f06e678d817b36aef84364c32848ec (diff)
util: Further API cleanups: (#8661)
* Turned `core_file` into an implementation of `random_read_write`. * Turned PNG errors into a standard error category. * Added a helper for generating what look like derived classes on-the-fly.
Diffstat (limited to 'src/devices')
-rw-r--r--src/devices/bus/a7800/a78_slot.cpp16
-rw-r--r--src/devices/bus/a800/a800_slot.cpp51
-rw-r--r--src/devices/bus/apf/slot.cpp8
-rw-r--r--src/devices/bus/aquarius/slot.cpp12
-rw-r--r--src/devices/bus/astrocde/slot.cpp8
-rw-r--r--src/devices/bus/chanf/slot.cpp8
-rw-r--r--src/devices/bus/coleco/cartridge/exp.cpp10
-rw-r--r--src/devices/bus/crvision/slot.cpp8
-rw-r--r--src/devices/bus/ekara/slot.cpp14
-rw-r--r--src/devices/bus/gamate/slot.cpp12
-rw-r--r--src/devices/bus/gameboy/gb_slot.cpp14
-rw-r--r--src/devices/bus/gba/gba_slot.cpp12
-rw-r--r--src/devices/bus/intv/slot.cpp16
-rw-r--r--src/devices/bus/isa/omti8621.cpp11
-rw-r--r--src/devices/bus/jakks_gamekey/slot.cpp14
-rw-r--r--src/devices/bus/megadrive/md_slot.cpp15
-rw-r--r--src/devices/bus/msx_slot/cartridge.cpp8
-rw-r--r--src/devices/bus/nes/aladdin.cpp16
-rw-r--r--src/devices/bus/nes/nes_slot.cpp11
-rw-r--r--src/devices/bus/nubus/nubus_image.cpp6
-rw-r--r--src/devices/bus/odyssey2/slot.cpp8
-rw-r--r--src/devices/bus/pce/pce_slot.cpp12
-rw-r--r--src/devices/bus/scv/slot.cpp12
-rw-r--r--src/devices/bus/sega8/sega8_slot.cpp15
-rw-r--r--src/devices/bus/snes/snes_slot.cpp9
-rw-r--r--src/devices/bus/ti99/gromport/cartridges.cpp5
-rw-r--r--src/devices/bus/vc4000/slot.cpp8
-rw-r--r--src/devices/bus/vcs/vcs_slot.cpp12
-rw-r--r--src/devices/bus/vectrex/slot.cpp16
-rw-r--r--src/devices/bus/wswan/slot.cpp13
-rw-r--r--src/devices/imagedev/cassette.cpp5
-rw-r--r--src/devices/imagedev/chd_cd.cpp5
-rw-r--r--src/devices/imagedev/diablo.cpp14
-rw-r--r--src/devices/imagedev/flopdrv.cpp3
-rw-r--r--src/devices/imagedev/floppy.cpp7
-rw-r--r--src/devices/imagedev/harddriv.cpp17
-rw-r--r--src/devices/imagedev/midiin.cpp2
-rw-r--r--src/devices/machine/hp_dc100_tape.cpp8
38 files changed, 243 insertions, 198 deletions
diff --git a/src/devices/bus/a7800/a78_slot.cpp b/src/devices/bus/a7800/a78_slot.cpp
index d55412058d1..65473693f62 100644
--- a/src/devices/bus/a7800/a78_slot.cpp
+++ b/src/devices/bus/a7800/a78_slot.cpp
@@ -508,16 +508,18 @@ std::string a78_cart_slot_device::get_default_card_software(get_default_card_sof
{
if (hook.image_file())
{
- const char *slot_string;
- std::vector<uint8_t> head(128);
- int type = A78_TYPE0, mapper;
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return
// Load and check the header
- hook.image_file()->read(&head[0], 128);
+ uint8_t head[128];
+ std::size_t actual;
+ hook.image_file()->read(&head[0], 128, actual); // FIXME: check error return or read returning short
// let's try to auto-fix some common errors in the header
- mapper = validate_header((head[53] << 8) | head[54], false);
+ int const mapper = validate_header((head[53] << 8) | head[54], false);
+ int type = A78_TYPE0;
switch (mapper & 0x2e)
{
case 0x0000:
@@ -534,7 +536,7 @@ std::string a78_cart_slot_device::get_default_card_software(get_default_card_sof
break;
case 0x0022:
case 0x0026:
- if (hook.image_file()->size() > 0x40000)
+ if (len > 0x40000)
type = A78_MEGACART;
else
type = A78_VERSABOARD;
@@ -560,7 +562,7 @@ std::string a78_cart_slot_device::get_default_card_software(get_default_card_sof
type = A78_TYPE8;
logerror("Cart type: %x\n", type);
- slot_string = a78_get_slot(type);
+ char const *const slot_string = a78_get_slot(type);
return std::string(slot_string);
}
diff --git a/src/devices/bus/a800/a800_slot.cpp b/src/devices/bus/a800/a800_slot.cpp
index 9ccbb170e1f..4ae54a22663 100644
--- a/src/devices/bus/a800/a800_slot.cpp
+++ b/src/devices/bus/a800/a800_slot.cpp
@@ -392,15 +392,16 @@ std::string a800_cart_slot_device::get_default_card_software(get_default_card_so
{
if (hook.image_file())
{
- const char *slot_string;
- std::vector<uint8_t> head(0x10);
- uint32_t len = hook.image_file()->size();
- int type = A800_8K;
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return
// check whether there is an header, to identify the cart type
+ int type = A800_8K;
if ((len % 0x1000) == 0x10)
{
- hook.image_file()->read(&head[0], 0x10);
+ size_t actual;
+ uint8_t head[0x10];
+ hook.image_file()->read(&head[0], 0x10, actual); // FIXME: check error return or read returning short
type = identify_cart_type(&head[0]);
}
else // otherwise try to guess based on size
@@ -414,12 +415,12 @@ std::string a800_cart_slot_device::get_default_card_software(get_default_card_so
if (type >= A5200_4K)
osd_printf_info("This game is not designed for A800. You might want to run it in A5200.\n");
- slot_string = a800_get_slot(type);
+ char const *const slot_string = a800_get_slot(type);
return std::string(slot_string);
}
- else
- return software_get_default_slot("a800_8k");
+
+ return software_get_default_slot("a800_8k");
}
@@ -427,15 +428,16 @@ std::string a5200_cart_slot_device::get_default_card_software(get_default_card_s
{
if (hook.image_file())
{
- const char *slot_string;
- std::vector<uint8_t> head(0x10);
- uint32_t len = hook.image_file()->size();
- int type = A5200_8K;
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return
// check whether there is an header, to identify the cart type
+ int type = A5200_8K;
if ((len % 0x1000) == 0x10)
{
- hook.image_file()->read(&head[0], 0x10);
+ size_t actual;
+ uint8_t head[0x10];
+ hook.image_file()->read(&head[0], 0x10, actual); // FIXME: check error return or read returning short
type = identify_cart_type(&head[0]);
}
else
@@ -447,12 +449,12 @@ std::string a5200_cart_slot_device::get_default_card_software(get_default_card_s
if (type < A5200_4K)
osd_printf_info("This game is not designed for A5200. You might want to run it in A800 or A800XL.\n");
- slot_string = a800_get_slot(type);
+ char const *const slot_string = a800_get_slot(type);
return std::string(slot_string);
}
- else
- return software_get_default_slot("a5200");
+
+ return software_get_default_slot("a5200");
}
@@ -460,15 +462,16 @@ std::string xegs_cart_slot_device::get_default_card_software(get_default_card_so
{
if (hook.image_file())
{
- const char *slot_string;
- std::vector<uint8_t> head(0x10);
- uint32_t len = hook.image_file()->size();
- int type = A800_8K;
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return
// check whether there is an header, to identify the cart type
+ int type = A800_8K;
if ((len % 0x1000) == 0x10)
{
- hook.image_file()->read(&head[0], 0x10);
+ size_t actual;
+ uint8_t head[0x10];
+ hook.image_file()->read(&head[0], 0x10, actual); // FIXME: check error return or read returning short
type = identify_cart_type(&head[0]);
}
if (type != A800_XEGS)
@@ -480,12 +483,12 @@ std::string xegs_cart_slot_device::get_default_card_software(get_default_card_so
osd_printf_info("You might want to run it in A800 or A800XL.\n");
}
- slot_string = a800_get_slot(type);
+ char const *const slot_string = a800_get_slot(type);
return std::string(slot_string);
}
- else
- return software_get_default_slot("xegs");
+
+ return software_get_default_slot("xegs");
}
diff --git a/src/devices/bus/apf/slot.cpp b/src/devices/bus/apf/slot.cpp
index c43738fae2a..31cd2abf2d4 100644
--- a/src/devices/bus/apf/slot.cpp
+++ b/src/devices/bus/apf/slot.cpp
@@ -202,17 +202,17 @@ std::string apf_cart_slot_device::get_default_card_software(get_default_card_sof
{
if (hook.image_file())
{
- const char *slot_string;
- uint32_t size = hook.image_file()->size();
- int type = APF_STD;
+ uint64_t size;
+ hook.image_file()->length(size); // FIXME: check error return
// attempt to identify Space Destroyer, which needs 1K of additional RAM
+ int type = APF_STD;
if (size == 0x1800)
type = APF_SPACEDST;
if (size > 0x2000)
type = APF_BASIC;
- slot_string = apf_get_slot(type);
+ char const *const slot_string = apf_get_slot(type);
//printf("type: %s\n", slot_string);
diff --git a/src/devices/bus/aquarius/slot.cpp b/src/devices/bus/aquarius/slot.cpp
index 88be36900f4..0c846b6f53b 100644
--- a/src/devices/bus/aquarius/slot.cpp
+++ b/src/devices/bus/aquarius/slot.cpp
@@ -117,15 +117,17 @@ std::string aquarius_cartridge_slot_device::get_default_card_software(get_defaul
if (hook.image_file())
{
- const char *slot_string = "rom";
- uint32_t len = hook.image_file()->size();
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return
+ const char *slot_string = "rom";
if (len >= 0x10000)
{
- std::vector<uint8_t> header(16);
+ uint8_t header[16];
- hook.image_file()->seek(len - 0x2000, SEEK_SET);
- hook.image_file()->read(&header[0], 16);
+ size_t actual;
+ hook.image_file()->seek(len - 0x2000, SEEK_SET); // FIXME: check error return
+ hook.image_file()->read(&header[0], 16, actual); // FIXME: check error return or read returning short
// detect SuperCart header
if (!memcmp(&header[0], SC08_HEADER, 16) || !memcmp(&header[0], SC16_HEADER, 16))
diff --git a/src/devices/bus/astrocde/slot.cpp b/src/devices/bus/astrocde/slot.cpp
index 0e72d9b57b9..b629c57322d 100644
--- a/src/devices/bus/astrocde/slot.cpp
+++ b/src/devices/bus/astrocde/slot.cpp
@@ -179,16 +179,16 @@ std::string astrocade_cart_slot_device::get_default_card_software(get_default_ca
{
if (hook.image_file())
{
- const char *slot_string;
- uint32_t size = hook.image_file()->size();
- int type = ASTROCADE_STD;
+ uint64_t size;
+ hook.image_file()->length(size); // FIXME: check error return
+ int type = ASTROCADE_STD;
if (size == 0x40000)
type = ASTROCADE_256K;
if (size == 0x80000)
type = ASTROCADE_512K;
- slot_string = astrocade_get_slot(type);
+ char const *const slot_string = astrocade_get_slot(type);
//printf("type: %s\n", slot_string);
diff --git a/src/devices/bus/chanf/slot.cpp b/src/devices/bus/chanf/slot.cpp
index f17e52653d0..3a4a9008c95 100644
--- a/src/devices/bus/chanf/slot.cpp
+++ b/src/devices/bus/chanf/slot.cpp
@@ -196,16 +196,16 @@ std::string channelf_cart_slot_device::get_default_card_software(get_default_car
{
if (hook.image_file())
{
- const char *slot_string;
- uint32_t len = hook.image_file()->size();
- int type;
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return
+ int type;
if (len == 0x40000)
type = CF_MULTI;
else
type = CF_CHESS; // is there any way to detect the other carts from fullpath?
- slot_string = chanf_get_slot(type);
+ char const *const slot_string = chanf_get_slot(type);
//printf("type: %s\n", slot_string);
diff --git a/src/devices/bus/coleco/cartridge/exp.cpp b/src/devices/bus/coleco/cartridge/exp.cpp
index 27c8bdff12c..cb12720f8dc 100644
--- a/src/devices/bus/coleco/cartridge/exp.cpp
+++ b/src/devices/bus/coleco/cartridge/exp.cpp
@@ -106,16 +106,16 @@ std::string colecovision_cartridge_slot_device::get_default_card_software(get_de
{
if (hook.image_file())
{
- uint32_t length = hook.image_file()->size();
+ uint64_t length;
+ hook.image_file()->length(length); // FIXME: check error return
+
if (length == 0x100000 || length == 0x200000)
return software_get_default_slot("xin1");
- if (length > 0x8000)
- {
- // Assume roms longer than 32K are megacarts.
+ if (length > 0x8000) // Assume roms longer than 32K are megacarts.
return software_get_default_slot("megacart");
- }
}
+
return software_get_default_slot("standard");
}
diff --git a/src/devices/bus/crvision/slot.cpp b/src/devices/bus/crvision/slot.cpp
index ce1e2a5ea1e..1c86b7ed332 100644
--- a/src/devices/bus/crvision/slot.cpp
+++ b/src/devices/bus/crvision/slot.cpp
@@ -209,10 +209,10 @@ std::string crvision_cart_slot_device::get_default_card_software(get_default_car
{
if (hook.image_file())
{
- const char *slot_string;
- uint32_t size = hook.image_file()->size();
- int type = CRV_4K;
+ uint64_t size;
+ hook.image_file()->length(size); // FIXME: check error return
+ int type = CRV_4K;
switch (size)
{
case 0x4800:
@@ -238,7 +238,7 @@ std::string crvision_cart_slot_device::get_default_card_software(get_default_car
break;
}
- slot_string = crvision_get_slot(type);
+ char const *const slot_string = crvision_get_slot(type);
//printf("type: %s\n", slot_string);
diff --git a/src/devices/bus/ekara/slot.cpp b/src/devices/bus/ekara/slot.cpp
index badba2b0ec1..459e14317b6 100644
--- a/src/devices/bus/ekara/slot.cpp
+++ b/src/devices/bus/ekara/slot.cpp
@@ -184,17 +184,17 @@ std::string ekara_cart_slot_device::get_default_card_software(get_default_card_s
{
if (hook.image_file())
{
- const char *slot_string;
- uint32_t len = hook.image_file()->size();
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return, guard against excessively large files
std::vector<uint8_t> rom(len);
- int type;
- hook.image_file()->read(&rom[0], len);
+ size_t actual;
+ hook.image_file()->read(&rom[0], len, actual); // FIXME: check error return or read returning short
- type = get_cart_type(&rom[0], len);
- slot_string = ekara_get_slot(type);
+ int const type = get_cart_type(&rom[0], len);
+ char const *const slot_string = ekara_get_slot(type);
- printf("type: %s\n", slot_string);
+ //printf("type: %s\n", slot_string);
return std::string(slot_string);
}
diff --git a/src/devices/bus/gamate/slot.cpp b/src/devices/bus/gamate/slot.cpp
index 3f98a30927d..869abf24f98 100644
--- a/src/devices/bus/gamate/slot.cpp
+++ b/src/devices/bus/gamate/slot.cpp
@@ -203,15 +203,15 @@ std::string gamate_cart_slot_device::get_default_card_software(get_default_card_
{
if (hook.image_file())
{
- const char *slot_string;
- uint32_t len = hook.image_file()->size();
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return, guard against excessively large files
std::vector<uint8_t> rom(len);
- int type;
- hook.image_file()->read(&rom[0], len);
+ size_t actual;
+ hook.image_file()->read(&rom[0], len, actual); // FIXME: check error return or read returning short
- type = get_cart_type(&rom[0], len);
- slot_string = gamate_get_slot(type);
+ int const type = get_cart_type(&rom[0], len);
+ char const *const slot_string = gamate_get_slot(type);
//printf("type: %s\n", slot_string);
diff --git a/src/devices/bus/gameboy/gb_slot.cpp b/src/devices/bus/gameboy/gb_slot.cpp
index 79708f95314..0da541e9f5a 100644
--- a/src/devices/bus/gameboy/gb_slot.cpp
+++ b/src/devices/bus/gameboy/gb_slot.cpp
@@ -584,21 +584,21 @@ std::string gb_cart_slot_device_base::get_default_card_software(get_default_card
{
if (hook.image_file())
{
- const char *slot_string;
- uint32_t len = hook.image_file()->size(), offset = 0;
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return, guard against excessively large files
std::vector<uint8_t> rom(len);
- int type;
- hook.image_file()->read(&rom[0], len);
+ size_t actual;
+ hook.image_file()->read(&rom[0], len, actual); // FIXME: check error return or read returning short
+ uint32_t offset = 0;
if ((len % 0x4000) == 512)
offset = 512;
-
if (get_mmm01_candidate(&rom[offset], len - offset))
offset += (len - 0x8000);
- type = get_cart_type(&rom[offset], len - offset);
- slot_string = gb_get_slot(type);
+ int const type = get_cart_type(&rom[offset], len - offset);
+ char const *const slot_string = gb_get_slot(type);
//printf("type: %s\n", slot_string);
diff --git a/src/devices/bus/gba/gba_slot.cpp b/src/devices/bus/gba/gba_slot.cpp
index ac036718e2d..f3a85302767 100644
--- a/src/devices/bus/gba/gba_slot.cpp
+++ b/src/devices/bus/gba/gba_slot.cpp
@@ -883,15 +883,15 @@ std::string gba_cart_slot_device::get_default_card_software(get_default_card_sof
{
if (hook.image_file())
{
- const char *slot_string;
- uint32_t len = hook.image_file()->size();
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return, guard against excessively large files
std::vector<uint8_t> rom(len);
- int type;
- hook.image_file()->read(&rom[0], len);
+ size_t actual;
+ hook.image_file()->read(&rom[0], len, actual); // FIXME: check error return or read returning short
- type = get_cart_type(&rom[0], len);
- slot_string = gba_get_slot(type);
+ int const type = get_cart_type(&rom[0], len);
+ char const *const slot_string = gba_get_slot(type);
//printf("type: %s\n", slot_string);
diff --git a/src/devices/bus/intv/slot.cpp b/src/devices/bus/intv/slot.cpp
index 3e086f9c530..727b5af2b5c 100644
--- a/src/devices/bus/intv/slot.cpp
+++ b/src/devices/bus/intv/slot.cpp
@@ -440,13 +440,14 @@ std::string intv_cart_slot_device::get_default_card_software(get_default_card_so
{
if (hook.image_file())
{
- const char *slot_string;
- uint32_t len = hook.image_file()->size();
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return, guard against excessively large files
std::vector<uint8_t> rom(len);
- int type = INTV_STD;
- hook.image_file()->read(&rom[0], len);
+ size_t actual;
+ hook.image_file()->read(&rom[0], len, actual); // FIXME: check error return or read returning short
+ int type = INTV_STD;
if (rom[0] == 0xa8 && (rom[1] == (rom[2] ^ 0xff)))
{
// it's .ROM file, so that we don't have currently any way to distinguish RAM-equipped carts
@@ -454,18 +455,17 @@ std::string intv_cart_slot_device::get_default_card_software(get_default_card_so
else
{
// assume it's .BIN and try to use .hsi file to determine type (just RAM)
- int start;
- int mapper, rom[5], ram, extra;
std::string extrainfo;
if (hook.hashfile_extrainfo(extrainfo))
{
+ int mapper, rom[5], ram, extra;
sscanf(extrainfo.c_str() ,"%d %d %d %d %d %d %d", &mapper, &rom[0], &rom[1], &rom[2],
&rom[3], &ram, &extra);
if (ram)
{
- start = ((ram & 0xf0) >> 4) * 0x1000;
+ int const start = ((ram & 0xf0) >> 4) * 0x1000;
if (start == 0xd000)
type = INTV_RAM;
if (start == 0x8800)
@@ -475,7 +475,7 @@ std::string intv_cart_slot_device::get_default_card_software(get_default_card_so
}
- slot_string = intv_get_slot(type);
+ char const *const slot_string = intv_get_slot(type);
//printf("type: %s\n", slot_string);
diff --git a/src/devices/bus/isa/omti8621.cpp b/src/devices/bus/isa/omti8621.cpp
index f14d6808291..f61ab0e905f 100644
--- a/src/devices/bus/isa/omti8621.cpp
+++ b/src/devices/bus/isa/omti8621.cpp
@@ -1458,9 +1458,9 @@ void omti_disk_image_device::device_reset()
{
logerror("device_reset_omti_disk\n");
- if (exists() && fseek(0, SEEK_END) == 0)
+ if (exists() && !fseek(0, SEEK_END))
{
- uint32_t disk_size = (uint32_t)(ftell() / OMTI_DISK_SECTOR_SIZE);
+ uint32_t disk_size = uint32_t(ftell() / OMTI_DISK_SECTOR_SIZE);
uint16_t disk_type = disk_size >= 300000 ? OMTI_DISK_TYPE_348_MB : OMTI_DISK_TYPE_155_MB;
if (disk_type != m_type) {
logerror("device_reset_omti_disk: disk size=%d blocks, disk type=%x\n", disk_size, disk_type);
@@ -1477,12 +1477,10 @@ image_init_result omti_disk_image_device::call_create(int format_type, util::opt
{
logerror("device_create_omti_disk: creating OMTI Disk with %d blocks\n", m_sector_count);
- int x;
unsigned char sectordata[OMTI_DISK_SECTOR_SIZE]; // empty block data
-
-
memset(sectordata, 0x55, sizeof(sectordata));
- for (x = 0; x < m_sector_count; x++)
+
+ for (int x = 0; x < m_sector_count; x++)
{
if (fwrite(sectordata, OMTI_DISK_SECTOR_SIZE)
< OMTI_DISK_SECTOR_SIZE)
@@ -1490,5 +1488,6 @@ image_init_result omti_disk_image_device::call_create(int format_type, util::opt
return image_init_result::FAIL;
}
}
+
return image_init_result::PASS;
}
diff --git a/src/devices/bus/jakks_gamekey/slot.cpp b/src/devices/bus/jakks_gamekey/slot.cpp
index e66e1fed6cd..f680211859a 100644
--- a/src/devices/bus/jakks_gamekey/slot.cpp
+++ b/src/devices/bus/jakks_gamekey/slot.cpp
@@ -182,17 +182,17 @@ std::string jakks_gamekey_slot_device::get_default_card_software(get_default_car
{
if (hook.image_file())
{
- const char *slot_string;
- uint32_t len = hook.image_file()->size();
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return, guard against excessively large files
std::vector<uint8_t> rom(len);
- int type;
- hook.image_file()->read(&rom[0], len);
+ size_t actual;
+ hook.image_file()->read(&rom[0], len, actual); // FIXME: check error return or read returning short
- type = get_cart_type(&rom[0], len);
- slot_string = jakks_gamekey_get_slot(type);
+ int const type = get_cart_type(&rom[0], len);
+ char const *const slot_string = jakks_gamekey_get_slot(type);
- printf("type: %s\n", slot_string);
+ //printf("type: %s\n", slot_string);
return std::string(slot_string);
}
diff --git a/src/devices/bus/megadrive/md_slot.cpp b/src/devices/bus/megadrive/md_slot.cpp
index f338fc25d87..47069101a44 100644
--- a/src/devices/bus/megadrive/md_slot.cpp
+++ b/src/devices/bus/megadrive/md_slot.cpp
@@ -906,18 +906,17 @@ std::string base_md_cart_slot_device::get_default_card_software(get_default_card
{
if (hook.image_file())
{
- const char *slot_string;
- uint32_t len = hook.image_file()->size(), offset = 0;
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return, guard against excessively large files
std::vector<uint8_t> rom(len);
- int type;
- hook.image_file()->read(&rom[0], len);
+ size_t actual;
+ hook.image_file()->read(&rom[0], len, actual); // FIXME: check error return or read returning short
- if (genesis_is_SMD(&rom[0x200], len - 0x200))
- offset = 0x200;
+ uint32_t const offset = genesis_is_SMD(&rom[0x200], len - 0x200) ? 0x200 : 0;
- type = get_cart_type(&rom[offset], len - offset);
- slot_string = md_get_slot(type);
+ int const type = get_cart_type(&rom[offset], len - offset);
+ char const *const slot_string = md_get_slot(type);
return std::string(slot_string);
}
diff --git a/src/devices/bus/msx_slot/cartridge.cpp b/src/devices/bus/msx_slot/cartridge.cpp
index 30c9f0a2b00..de998d6d2c8 100644
--- a/src/devices/bus/msx_slot/cartridge.cpp
+++ b/src/devices/bus/msx_slot/cartridge.cpp
@@ -278,8 +278,6 @@ std::string msx_slot_cartridge_device::get_default_card_software(get_default_car
if (hook.image_file())
{
const char *slot_string = "nomapper";
- uint32_t length = hook.image_file()->size();
- std::vector<uint8_t> rom(length);
int type = NOMAPPER;
// Check if there's some mapper related information in the hashfiles
@@ -323,7 +321,11 @@ std::string msx_slot_cartridge_device::get_default_card_software(get_default_car
if (type == NOMAPPER)
{
// Not identified through hashfile, try automatic detection
- hook.image_file()->read(&rom[0], length);
+ uint64_t length;
+ hook.image_file()->length(length); // FIXME: check error return, guard against excessively large files
+ std::vector<uint8_t> rom(length);
+ size_t actual;
+ hook.image_file()->read(&rom[0], length, actual); // FIXME: check error return or read returning short
type = get_cart_type(&rom[0], length);
}
diff --git a/src/devices/bus/nes/aladdin.cpp b/src/devices/bus/nes/aladdin.cpp
index 27f6c975201..325fd7bf87d 100644
--- a/src/devices/bus/nes/aladdin.cpp
+++ b/src/devices/bus/nes/aladdin.cpp
@@ -141,16 +141,16 @@ std::string nes_aladdin_slot_device::get_default_card_software(get_default_card_
{
if (hook.image_file())
{
- const char *slot_string = "algn";
- uint32_t len = hook.image_file()->size();
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return, guard against excessively large files
std::vector<uint8_t> rom(len);
- uint8_t mapper;
- hook.image_file()->read(&rom[0], len);
+ size_t actual;
+ hook.image_file()->read(&rom[0], len, actual); // FIXME: check error return or read returning short
- mapper = (rom[6] & 0xf0) >> 4;
- mapper |= rom[7] & 0xf0;
+ uint8_t const mapper = ((rom[6] & 0xf0) >> 4) | (rom[7] & 0xf0);
+ const char *slot_string = "algn";
// if (mapper == 71)
// slot_string = "algn";
if (mapper == 232)
@@ -158,8 +158,8 @@ std::string nes_aladdin_slot_device::get_default_card_software(get_default_card_
return std::string(slot_string);
}
- else
- return software_get_default_slot("algn");
+
+ return software_get_default_slot("algn");
}
diff --git a/src/devices/bus/nes/nes_slot.cpp b/src/devices/bus/nes/nes_slot.cpp
index fef76b520d0..53fc0a2f058 100644
--- a/src/devices/bus/nes/nes_slot.cpp
+++ b/src/devices/bus/nes/nes_slot.cpp
@@ -944,16 +944,17 @@ std::string nes_cart_slot_device::get_default_card_software(get_default_card_sof
{
if (hook.image_file())
{
- const char *slot_string = "nrom";
- uint32_t len = hook.image_file()->size();
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return, guard against excessively large files
std::vector<uint8_t> rom(len);
- hook.image_file()->read(&rom[0], len);
+ size_t actual;
+ hook.image_file()->read(&rom[0], len, actual); // FIXME: check error return or read returning short
+ const char *slot_string = "nrom";
if ((rom[0] == 'N') && (rom[1] == 'E') && (rom[2] == 'S'))
slot_string = get_default_card_ines(hook, &rom[0], len);
-
- if ((rom[0] == 'U') && (rom[1] == 'N') && (rom[2] == 'I') && (rom[3] == 'F'))
+ else if ((rom[0] == 'U') && (rom[1] == 'N') && (rom[2] == 'I') && (rom[3] == 'F'))
slot_string = get_default_card_unif(&rom[0], len);
return std::string(slot_string);
diff --git a/src/devices/bus/nubus/nubus_image.cpp b/src/devices/bus/nubus/nubus_image.cpp
index f017b9cc5a1..bcf072338a6 100644
--- a/src/devices/bus/nubus/nubus_image.cpp
+++ b/src/devices/bus/nubus/nubus_image.cpp
@@ -86,16 +86,16 @@ void nubus_image_device::messimg_disk_image_device::device_start()
{
m_data = nullptr;
- if (exists() && fseek(0, SEEK_END) == 0)
+ if (exists() && !fseek(0, SEEK_END))
{
- m_size = (uint32_t)ftell();
+ m_size = uint32_t(ftell());
}
}
image_init_result nubus_image_device::messimg_disk_image_device::call_load()
{
fseek(0, SEEK_END);
- m_size = (uint32_t)ftell();
+ m_size = uint32_t(ftell());
if (m_size > (256*1024*1024))
{
osd_printf_error("Mac image too large: must be 256MB or less!\n");
diff --git a/src/devices/bus/odyssey2/slot.cpp b/src/devices/bus/odyssey2/slot.cpp
index ced47e99955..2abeb58737a 100644
--- a/src/devices/bus/odyssey2/slot.cpp
+++ b/src/devices/bus/odyssey2/slot.cpp
@@ -182,10 +182,10 @@ std::string o2_cart_slot_device::get_default_card_software(get_default_card_soft
{
if (hook.image_file())
{
- const char *slot_string;
- u32 size = hook.image_file()->size();
- int type = (size == 0x4000) ? O2_RALLY : O2_STD;
- slot_string = o2_get_slot(type);
+ uint64_t size;
+ hook.image_file()->length(size); // FIXME: check error return
+ int const type = (size == 0x4000) ? O2_RALLY : O2_STD;
+ char const *const slot_string = o2_get_slot(type);
return std::string(slot_string);
}
diff --git a/src/devices/bus/pce/pce_slot.cpp b/src/devices/bus/pce/pce_slot.cpp
index b9a65757afa..8f52410a1a3 100644
--- a/src/devices/bus/pce/pce_slot.cpp
+++ b/src/devices/bus/pce/pce_slot.cpp
@@ -321,15 +321,15 @@ std::string pce_cart_slot_device::get_default_card_software(get_default_card_sof
{
if (hook.image_file())
{
- const char *slot_string;
- uint32_t len = hook.image_file()->size();
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return, guard against excessively large files
std::vector<uint8_t> rom(len);
- int type;
- hook.image_file()->read(&rom[0], len);
+ size_t actual;
+ hook.image_file()->read(&rom[0], len, actual); // FIXME: check error return or read returning short
- type = get_cart_type(&rom[0], len);
- slot_string = pce_get_slot(type);
+ int const type = get_cart_type(&rom[0], len);
+ char const *const slot_string = pce_get_slot(type);
//printf("type: %s\n", slot_string);
diff --git a/src/devices/bus/scv/slot.cpp b/src/devices/bus/scv/slot.cpp
index 86dc2d810c1..0d63399faea 100644
--- a/src/devices/bus/scv/slot.cpp
+++ b/src/devices/bus/scv/slot.cpp
@@ -238,15 +238,15 @@ std::string scv_cart_slot_device::get_default_card_software(get_default_card_sof
{
if (hook.image_file())
{
- const char *slot_string;
- uint32_t len = hook.image_file()->size();
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return, guard against excessively large files
std::vector<uint8_t> rom(len);
- int type;
- hook.image_file()->read(&rom[0], len);
+ size_t actual;
+ hook.image_file()->read(&rom[0], len, actual); // FIXME: check error return or read returning short
- type = get_cart_type(&rom[0], len);
- slot_string = scv_get_slot(type);
+ int const type = get_cart_type(&rom[0], len);
+ char const *const slot_string = scv_get_slot(type);
//printf("type: %s\n", slot_string);
diff --git a/src/devices/bus/sega8/sega8_slot.cpp b/src/devices/bus/sega8/sega8_slot.cpp
index 8a998e71bf0..e6d6f17a5f4 100644
--- a/src/devices/bus/sega8/sega8_slot.cpp
+++ b/src/devices/bus/sega8/sega8_slot.cpp
@@ -666,18 +666,17 @@ std::string sega8_cart_slot_device::get_default_card_software(get_default_card_s
{
if (hook.image_file())
{
- const char *slot_string;
- uint32_t len = hook.image_file()->size(), offset = 0;
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return, guard against excessively large files
std::vector<uint8_t> rom(len);
- int type;
- hook.image_file()->read(&rom[0], len);
+ size_t actual;
+ hook.image_file()->read(&rom[0], len, actual); // FIXME: check error return or read returning short
- if ((len % 0x4000) == 512)
- offset = 512;
+ uint32_t const offset = ((len % 0x4000) == 512) ? 512 : 0;
- type = get_cart_type(&rom[offset], len - offset);
- slot_string = sega8_get_slot(type);
+ int const type = get_cart_type(&rom[offset], len - offset);
+ char const *const slot_string = sega8_get_slot(type);
//printf("type: %s\n", slot_string);
diff --git a/src/devices/bus/snes/snes_slot.cpp b/src/devices/bus/snes/snes_slot.cpp
index 7c7d4d9ea08..5f84ea91683 100644
--- a/src/devices/bus/snes/snes_slot.cpp
+++ b/src/devices/bus/snes/snes_slot.cpp
@@ -1021,13 +1021,14 @@ std::string base_sns_cart_slot_device::get_default_card_software(get_default_car
{
if (hook.image_file())
{
- const char *slot_string;
uint32_t offset;
- uint32_t len = hook.image_file()->size();
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return, guard against excessively large file
std::vector<uint8_t> rom(len);
int type = 0, addon = 0;
- hook.image_file()->read(&rom[0], len);
+ size_t actual;
+ hook.image_file()->read(&rom[0], len, actual); // FIXME: check for error result or read returning short
offset = snes_skip_header(&rom[0], len);
@@ -1070,7 +1071,7 @@ std::string base_sns_cart_slot_device::get_default_card_software(get_default_car
break;
}
- slot_string = sns_get_slot(type);
+ char const *const slot_string = sns_get_slot(type);
return std::string(slot_string);
}
diff --git a/src/devices/bus/ti99/gromport/cartridges.cpp b/src/devices/bus/ti99/gromport/cartridges.cpp
index b4c3655a7e5..bc9c539fc9a 100644
--- a/src/devices/bus/ti99/gromport/cartridges.cpp
+++ b/src/devices/bus/ti99/gromport/cartridges.cpp
@@ -257,7 +257,10 @@ image_init_result ti99_cartridge_device::call_load()
}
else
{
- std::error_condition err = rpk_open(machine().options(), util::core_file_read(image_core_file()), machine().system().name, m_rpk);
+ util::core_file::ptr proxy;
+ std::error_condition err = util::core_file::open_proxy(image_core_file(), proxy);
+ if (!err)
+ err = rpk_open(machine().options(), std::move(proxy), machine().system().name, m_rpk);
if (err)
{
LOGMASKED(LOG_WARN, "Failed to load cartridge '%s': %s\n", basename(), err.message().c_str());
diff --git a/src/devices/bus/vc4000/slot.cpp b/src/devices/bus/vc4000/slot.cpp
index 8de01177448..94de9446dc2 100644
--- a/src/devices/bus/vc4000/slot.cpp
+++ b/src/devices/bus/vc4000/slot.cpp
@@ -226,17 +226,17 @@ std::string vc4000_cart_slot_device::get_default_card_software(get_default_card_
{
if (hook.image_file())
{
- const char *slot_string;
- uint32_t size = hook.image_file()->size();
+ std::uint64_t size;
+ hook.image_file()->length(size); // FIXME: check error result
int type = VC4000_STD;
// attempt to identify the non-standard types
if (size > 0x1000) // 6k rom + 1k ram - Chess2 only
type = VC4000_CHESS2;
- else if (size > 0x0800) // some 4k roms have 1k of mirrored ram
+ else if (size > 0x0800) // some 4k roms have 1k of mirrored RAM
type = VC4000_RAM1K;
- slot_string = vc4000_get_slot(type);
+ char const *const slot_string = vc4000_get_slot(type);
//printf("type: %s\n", slot_string);
diff --git a/src/devices/bus/vcs/vcs_slot.cpp b/src/devices/bus/vcs/vcs_slot.cpp
index 5efcc4ba32d..3d0fe0e4fb9 100644
--- a/src/devices/bus/vcs/vcs_slot.cpp
+++ b/src/devices/bus/vcs/vcs_slot.cpp
@@ -762,15 +762,15 @@ std::string vcs_cart_slot_device::get_default_card_software(get_default_card_sof
{
if (hook.image_file())
{
- const char *slot_string;
- uint32_t len = hook.image_file()->size();
+ uint64_t len;
+ hook.image_file()->length(len); // FIXME: check error return, guard against excessively large files
std::vector<uint8_t> rom(len);
- int type;
- hook.image_file()->read(&rom[0], len);
+ size_t actual;
+ hook.image_file()->read(&rom[0], len, actual); // FIXME: check error return or read returning short
- type = identify_cart_type(&rom[0], len);
- slot_string = vcs_get_slot(type);
+ int const type = identify_cart_type(&rom[0], len);
+ char const *const slot_string = vcs_get_slot(type);
return std::string(slot_string);
}
diff --git a/src/devices/bus/vectrex/slot.cpp b/src/devices/bus/vectrex/slot.cpp
index 9e3ebd14fa6..ffb7f515379 100644
--- a/src/devices/bus/vectrex/slot.cpp
+++ b/src/devices/bus/vectrex/slot.cpp
@@ -198,19 +198,21 @@ std::string vectrex_cart_slot_device::get_default_card_software(get_default_card
{
if (hook.image_file())
{
- const char *slot_string;
- uint32_t size = hook.image_file()->size();
+ // FIXME: consider oversize files, check for errors, and check for read returning early
+ // it's also really wasteful to read the whole file here when only a small part of it is used for identification
+ std::uint64_t size;
+ hook.image_file()->length(size);
std::vector<uint8_t> rom(size);
- int type = VECTREX_STD;
-
- hook.image_file()->read(&rom[0], size);
+ std::size_t actual;
+ hook.image_file()->read(&rom[0], size, actual);
- if (!memcmp(&rom[0x06], "SRAM", 4))
+ int type = VECTREX_STD;
+ if (!memcmp(&rom[0x06], "SRAM", 4)) // FIXME: bounds check!
type = VECTREX_SRAM;
if (size > 0x8000)
type = VECTREX_64K;
- slot_string = vectrex_get_slot(type);
+ char const *const slot_string = vectrex_get_slot(type);
//printf("type: %s\n", slot_string);
diff --git a/src/devices/bus/wswan/slot.cpp b/src/devices/bus/wswan/slot.cpp
index d890917db87..3e11eb00908 100644
--- a/src/devices/bus/wswan/slot.cpp
+++ b/src/devices/bus/wswan/slot.cpp
@@ -277,13 +277,22 @@ std::string ws_cart_slot_device::get_default_card_software(get_default_card_soft
{
if (hook.image_file())
{
+ // FIXME: multiple issues in this function
+ // * Check for error from getting file length
+ // * Check for file length too large for size_t
+ // * File length is bytes but vector is sized in words
+ // * Catch out-of-memory when resizing vector
+ // * Check for error reading
+ // * Consider big-endian hosts - word data needs swapping
const char *slot_string;
- u32 size = hook.image_file()->size();
+ std::uint64_t size = 0;
+ hook.image_file()->length(size);
std::vector<u16> rom(size);
int type;
u32 nvram;
- hook.image_file()->read(&rom[0], size);
+ size_t actual;
+ hook.image_file()->read(&rom[0], size, actual);
// nvram size is not really used here, but we set it up nevertheless
type = get_cart_type(&rom[0], size, nvram);
diff --git a/src/devices/imagedev/cassette.cpp b/src/devices/imagedev/cassette.cpp
index 52103cb1e7d..338f1ed7413 100644
--- a/src/devices/imagedev/cassette.cpp
+++ b/src/devices/imagedev/cassette.cpp
@@ -14,6 +14,7 @@
#include "formats/imageutl.h"
#include "util/ioprocs.h"
+#include "util/ioprocsfilter.h"
#define LOG_WARN (1U<<1) // Warnings
#define LOG_DETAIL (1U<<2) // Details
@@ -260,7 +261,7 @@ image_init_result cassette_image_device::internal_load(bool is_create)
check_for_file();
if (is_create || (length()==0)) // empty existing images are fine to write over.
{
- auto io = util::core_file_read_write(image_core_file(), 0x00);
+ auto io = util::random_read_write_fill(image_core_file(), 0x00);
if (io)
{
// creating an image
@@ -285,7 +286,7 @@ image_init_result cassette_image_device::internal_load(bool is_create)
// we probably don't want to retry...
retry = false;
- auto io = util::core_file_read_write(image_core_file(), 0x00);
+ auto io = util::random_read_write_fill(image_core_file(), 0x00);
if (io)
{
// try opening the cassette
diff --git a/src/devices/imagedev/chd_cd.cpp b/src/devices/imagedev/chd_cd.cpp
index 4eacb3d3b58..753a7b88212 100644
--- a/src/devices/imagedev/chd_cd.cpp
+++ b/src/devices/imagedev/chd_cd.cpp
@@ -91,7 +91,10 @@ image_init_result cdrom_image_device::call_load()
if (!loaded_through_softlist()) {
if (is_filetype("chd") && is_loaded()) {
- err = m_self_chd.open(util::core_file_read_write(image_core_file())); // CDs are never writeable
+ util::core_file::ptr proxy;
+ err = util::core_file::open_proxy(image_core_file(), proxy);
+ if (!err)
+ err = m_self_chd.open(std::move(proxy)); // CDs are never writeable
if (err)
goto error;
chd = &m_self_chd;
diff --git a/src/devices/imagedev/diablo.cpp b/src/devices/imagedev/diablo.cpp
index 0a4107ac90a..cdc7665f61d 100644
--- a/src/devices/imagedev/diablo.cpp
+++ b/src/devices/imagedev/diablo.cpp
@@ -127,7 +127,10 @@ image_init_result diablo_image_device::call_create(int create_format, util::opti
/* create the CHD file */
chd_codec_type compression[4] = { CHD_CODEC_NONE };
- std::error_condition err = m_origchd.create(util::core_file_read_write(image_core_file()), uint64_t(totalsectors) * uint64_t(sectorsize), hunksize, sectorsize, compression);
+ util::core_file::ptr proxy;
+ std::error_condition err = util::core_file::open_proxy(image_core_file(), proxy);
+ if (!err)
+ m_origchd.create(std::move(proxy), uint64_t(totalsectors) * uint64_t(sectorsize), hunksize, sectorsize, compression);
if (err)
return image_init_result::FAIL;
@@ -219,14 +222,19 @@ image_init_result diablo_image_device::internal_load_dsk()
}
else
{
- err = m_origchd.open(util::core_file_read_write(image_core_file()), true);
+ util::core_file::ptr proxy;
+ err = util::core_file::open_proxy(image_core_file(), proxy);
+ if (!err)
+ err = m_origchd.open(std::move(proxy), true);
if (!err)
{
m_chd = &m_origchd;
}
else if (err == chd_file::error::FILE_NOT_WRITEABLE)
{
- err = m_origchd.open(util::core_file_read_write(image_core_file()), false);
+ err = util::core_file::open_proxy(image_core_file(), proxy);
+ if (!err)
+ err = m_origchd.open(std::move(proxy), false);
if (!err)
{
err = open_disk_diff(device().machine().options(), basename_noext(), m_origchd, m_diffchd);
diff --git a/src/devices/imagedev/flopdrv.cpp b/src/devices/imagedev/flopdrv.cpp
index 316b66ef713..1188519d648 100644
--- a/src/devices/imagedev/flopdrv.cpp
+++ b/src/devices/imagedev/flopdrv.cpp
@@ -19,6 +19,7 @@
#include "formats/imageutl.h"
#include "util/ioprocs.h"
+#include "util/ioprocsfilter.h"
#define VERBOSE 0
@@ -426,7 +427,7 @@ image_init_result legacy_floppy_image_device::internal_floppy_device_load(bool i
floperr_t err;
check_for_file();
- auto io = util::core_file_read_write(image_core_file(), 0xff);
+ auto io = util::random_read_write_fill(image_core_file(), 0xff);
if (!io)
{
err = FLOPPY_ERROR_OUTOFMEMORY;
diff --git a/src/devices/imagedev/floppy.cpp b/src/devices/imagedev/floppy.cpp
index 5d3956e2cab..00d4b77ecd3 100644
--- a/src/devices/imagedev/floppy.cpp
+++ b/src/devices/imagedev/floppy.cpp
@@ -30,6 +30,7 @@
#include "formats/imageutl.h"
#include "util/ioprocs.h"
+#include "util/ioprocsfilter.h"
#include "util/zippath.h"
/*
@@ -403,7 +404,7 @@ void floppy_image_device::commit_image()
return;
check_for_file();
- auto io = util::core_file_read_write(image_core_file(), 0xff);
+ auto io = util::random_read_write_fill(image_core_file(), 0xff);
if(!io) {
popmessage("Error, out of memory");
return;
@@ -543,7 +544,7 @@ floppy_image_format_t *floppy_image_device::identify(std::string filename)
return nullptr;
}
- auto io = util::core_file_read(std::move(fd), 0xff);
+ auto io = util::random_read_fill(std::move(fd), 0xff);
if(!io) {
seterror(std::errc::not_enough_memory, nullptr);
return nullptr;
@@ -591,7 +592,7 @@ void floppy_image_device::init_floppy_load(bool write_supported)
image_init_result floppy_image_device::call_load()
{
check_for_file();
- auto io = util::core_file_read(image_core_file(), 0xff);
+ auto io = util::random_read_fill(image_core_file(), 0xff);
if(!io) {
seterror(std::errc::not_enough_memory, nullptr);
return image_init_result::FAIL;
diff --git a/src/devices/imagedev/harddriv.cpp b/src/devices/imagedev/harddriv.cpp
index 384bc8c3e92..ff623d58150 100644
--- a/src/devices/imagedev/harddriv.cpp
+++ b/src/devices/imagedev/harddriv.cpp
@@ -148,7 +148,10 @@ image_init_result harddisk_image_device::call_create(int create_format, util::op
/* create the CHD file */
chd_codec_type compression[4] = { CHD_CODEC_NONE };
- std::error_condition err = m_origchd.create(util::core_file_read_write(image_core_file()), (uint64_t)totalsectors * (uint64_t)sectorsize, hunksize, sectorsize, compression);
+ util::core_file::ptr proxy;
+ std::error_condition err = util::core_file::open_proxy(image_core_file(), proxy);
+ if (!err)
+ err = m_origchd.create(std::move(proxy), uint64_t(totalsectors) * uint64_t(sectorsize), hunksize, sectorsize, compression);
if (err)
return image_init_result::FAIL;
@@ -250,7 +253,10 @@ image_init_result harddisk_image_device::internal_load_hd()
if (!memcmp("MComprHD", header, 8))
{
- err = m_origchd.open(util::core_file_read_write(image_core_file()), true);
+ util::core_file::ptr proxy;
+ err = util::core_file::open_proxy(image_core_file(), proxy);
+ if (!err)
+ err = m_origchd.open(std::move(proxy), true);
if (!err)
{
@@ -258,7 +264,10 @@ image_init_result harddisk_image_device::internal_load_hd()
}
else if (err == chd_file::error::FILE_NOT_WRITEABLE)
{
- err = m_origchd.open(util::core_file_read_write(image_core_file()), false);
+ err = util::core_file::open_proxy(image_core_file(), proxy);
+ if (!err)
+ err = m_origchd.open(std::move(proxy), false);
+
if (!err)
{
err = open_disk_diff(device().machine().options(), basename_noext(), m_origchd, m_diffchd);
@@ -295,7 +304,7 @@ image_init_result harddisk_image_device::internal_load_hd()
{
skip = header[0x8] | (header[0x9] << 8) | (header[0xa] << 16) | (header[0xb] << 24);
uint32_t data_size = header[0xc] | (header[0xd] << 8) | (header[0xe] << 16) | (header[0xf] << 24);
- if (data_size == image_core_file().size() - skip)
+ if (data_size == length() - skip)
{
osd_printf_verbose("harddriv: detected Anex86 HDI, data at %08x\n", skip);
}
diff --git a/src/devices/imagedev/midiin.cpp b/src/devices/imagedev/midiin.cpp
index e2386afb532..63afc1c83f5 100644
--- a/src/devices/imagedev/midiin.cpp
+++ b/src/devices/imagedev/midiin.cpp
@@ -134,7 +134,7 @@ image_init_result midiin_device::call_load()
// if the parsing succeeds, schedule the start to happen at least
// 10 seconds after starting to allow the keyboards to initialize
// TODO: this should perhaps be a driver-configurable parameter?
- if (m_sequence.parse(reinterpret_cast<u8 *>(ptr()), length()))
+ if (m_sequence.parse(reinterpret_cast<u8 const *>(ptr()), length()))
{
m_sequence_start = std::max(machine().time(), attotime(10, 0));
m_timer->adjust(attotime::zero);
diff --git a/src/devices/machine/hp_dc100_tape.cpp b/src/devices/machine/hp_dc100_tape.cpp
index 7d068af39d6..23cf9e4bead 100644
--- a/src/devices/machine/hp_dc100_tape.cpp
+++ b/src/devices/machine/hp_dc100_tape.cpp
@@ -30,7 +30,7 @@
#include "emu.h"
#include "hp_dc100_tape.h"
-#include "util/ioprocs.h"
+#include "util/ioprocsfilter.h"
// Debugging
#include "logmacro.h"
@@ -110,7 +110,7 @@ void hp_dc100_tape_device::call_unload()
if (m_image_dirty) {
check_for_file();
- auto io = util::core_file_read_write(image_core_file(), 0);
+ auto io = util::random_read_write_fill(image_core_file(), 0);
if (io) {
m_image.save_tape(*io);
m_image_dirty = false;
@@ -606,7 +606,7 @@ image_init_result hp_dc100_tape_device::internal_load(bool is_create)
check_for_file();
if (is_create) {
- auto io = util::core_file_read_write(image_core_file(), 0);
+ auto io = util::random_read_write_fill(image_core_file(), 0);
if (!io) {
LOG("out of memory\n");
seterror(std::errc::not_enough_memory, nullptr);
@@ -616,7 +616,7 @@ image_init_result hp_dc100_tape_device::internal_load(bool is_create)
m_image.clear_tape();
m_image.save_tape(*io);
} else {
- auto io = util::core_file_read(image_core_file(), 0);
+ auto io = util::random_read_fill(image_core_file(), 0);
if (!io) {
LOG("out of memory\n");
seterror(std::errc::not_enough_memory, nullptr);