diff options
author | 2021-08-22 09:06:15 +1000 | |
---|---|---|
committer | 2021-08-22 09:06:15 +1000 | |
commit | e8bbea1fc6e94e14768509d322f6c624403ffb36 (patch) | |
tree | 74dd1606a900d83de8aecff17a6737af4113308d /src/lib/formats/cqm_dsk.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/lib/formats/cqm_dsk.cpp')
-rw-r--r-- | src/lib/formats/cqm_dsk.cpp | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/src/lib/formats/cqm_dsk.cpp b/src/lib/formats/cqm_dsk.cpp index 5f79a4d3694..6639e50f801 100644 --- a/src/lib/formats/cqm_dsk.cpp +++ b/src/lib/formats/cqm_dsk.cpp @@ -8,9 +8,12 @@ *********************************************************************/ +#include "cqm_dsk.h" + +#include "ioprocs.h" + #include <cstring> -#include <cassert> -#include "flopimg.h" + #define CQM_HEADER_SIZE 133 @@ -231,17 +234,6 @@ FLOPPY_CONSTRUCT( cqm_dsk_construct ) - -/********************************************************************* - - formats/cqm_dsk.c - - CopyQM disk images - -*********************************************************************/ - -#include "cqm_dsk.h" - cqm_format::cqm_format() { } @@ -261,10 +253,11 @@ const char *cqm_format::extensions() const return "cqm,cqi,dsk"; } -int cqm_format::identify(io_generic *io, uint32_t form_factor, const std::vector<uint32_t> &variants) +int cqm_format::identify(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants) { uint8_t h[3]; - io_generic_read(io, h, 0, 3); + size_t actual; + io.read_at(0, h, 3, actual); if (h[0] == 'C' && h[1] == 'Q' && h[2] == 0x14) return 100; @@ -272,12 +265,13 @@ int cqm_format::identify(io_generic *io, uint32_t form_factor, const std::vector return 0; } -bool cqm_format::load(io_generic *io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image *image) +bool cqm_format::load(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image *image) { + size_t actual; const int max_size = 4*1024*1024; // 4MB ought to be large enough for any floppy std::vector<uint8_t> imagebuf(max_size); uint8_t header[CQM_HEADER_SIZE]; - io_generic_read(io, header, 0, CQM_HEADER_SIZE); + io.read_at(0, header, CQM_HEADER_SIZE, actual); int sector_size = (header[0x04] << 8) | header[0x03]; int sector_per_track = (header[0x11] << 8) | header[0x10]; @@ -318,9 +312,11 @@ bool cqm_format::load(io_generic *io, uint32_t form_factor, const std::vector<ui int rpm = form_factor == floppy_image::FF_8 || (form_factor == floppy_image::FF_525 && rate >= 300000) ? 360 : 300; int base_cell_count = rate*60/rpm; - int cqm_size = io_generic_size(io); + uint64_t cqm_size; + if (io.length(cqm_size)) + return false; std::vector<uint8_t> cqmbuf(cqm_size); - io_generic_read(io, &cqmbuf[0], 0, cqm_size); + io.read_at(0, &cqmbuf[0], cqm_size, actual); // decode the RLE data for (int s = 0, pos = CQM_HEADER_SIZE + comment_size; pos < cqm_size; ) @@ -369,7 +365,7 @@ bool cqm_format::load(io_generic *io, uint32_t form_factor, const std::vector<ui return true; } -bool cqm_format::save(io_generic *io, const std::vector<uint32_t> &variants, floppy_image *image) +bool cqm_format::save(util::random_read_write &io, const std::vector<uint32_t> &variants, floppy_image *image) { return false; } |