diff options
Diffstat (limited to 'src/lib/formats/dfi_dsk.cpp')
-rw-r--r-- | src/lib/formats/dfi_dsk.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/lib/formats/dfi_dsk.cpp b/src/lib/formats/dfi_dsk.cpp index a0d216002bd..e2ea1fda0e3 100644 --- a/src/lib/formats/dfi_dsk.cpp +++ b/src/lib/formats/dfi_dsk.cpp @@ -18,6 +18,8 @@ #include "osdcore.h" // osd_printf_* +#include <tuple> + #define NUMBER_OF_MULTIREADS 3 // thresholds for brickwall windowing @@ -63,16 +65,23 @@ bool dfi_format::supports_save() const noexcept int dfi_format::identify(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants) const { char sign[4]; - size_t actual; - io.read_at(0, sign, 4, actual); + auto const [err, actual] = read_at(io, 0, sign, 4); + if(err || (4 != actual)) { + return 0; + } return memcmp(sign, "DFE2", 4) ? 0 : FIFID_SIGN; } bool dfi_format::load(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image &image) const { + std::error_condition err; size_t actual; + char sign[4]; - io.read_at(0, sign, 4, actual); + std::tie(err, actual) = read_at(io, 0, sign, 4); + if(err || (4 != actual)) { + return false; + } if(memcmp(sign, "DFER", 4) == 0) { osd_printf_error("dfi_dsk: Old type Discferret image detected; the MAME Discferret decoder will not handle this properly, bailing out!\n"); return false; @@ -89,7 +98,7 @@ bool dfi_format::load(util::random_read &io, uint32_t form_factor, const std::ve [[maybe_unused]] int rpm=360; // drive rpm while(pos < size) { uint8_t h[10]; - io.read_at(pos, h, 10, actual); + std::tie(err, actual) = read_at(io, pos, h, 10); // FIXME: check for errors and premature EOF uint16_t track = get_u16be(&h[0]); uint16_t head = get_u16be(&h[2]); // Ignore sector @@ -105,7 +114,7 @@ bool dfi_format::load(util::random_read &io, uint32_t form_factor, const std::ve data.resize(tsize); pos += 10; // skip the header, we already read it - io.read_at(pos, &data[0], tsize, actual); + std::tie(err, actual) = read_at(io, pos, &data[0], tsize); // FIXME: check for errors and premature EOF pos += tsize; // for next time we read, increment to the beginning of next header int index_time = 0; // what point the last index happened |