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/ccvf_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/ccvf_dsk.cpp')
-rw-r--r-- | src/lib/formats/ccvf_dsk.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/lib/formats/ccvf_dsk.cpp b/src/lib/formats/ccvf_dsk.cpp index bba52d3922a..6ed0c14038a 100644 --- a/src/lib/formats/ccvf_dsk.cpp +++ b/src/lib/formats/ccvf_dsk.cpp @@ -11,6 +11,7 @@ #include "formats/ccvf_dsk.h" #include "coretmpl.h" // BIT +#include "ioprocs.h" ccvf_format::ccvf_format() @@ -46,12 +47,12 @@ const ccvf_format::format ccvf_format::file_formats[] = { {} }; -int ccvf_format::identify(io_generic *io, uint32_t form_factor, const std::vector<uint32_t> &variants) +int ccvf_format::identify(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants) { char h[36]; - - io_generic_read(io, h, 0, 36); - if(!memcmp(h, "Compucolor Virtual Floppy Disk Image", 36)) + size_t actual; + io.read_at(0, h, 36, actual); + if (!memcmp(h, "Compucolor Virtual Floppy Disk Image", 36)) return 100; return 0; @@ -87,13 +88,17 @@ floppy_image_format_t::desc_e* ccvf_format::get_desc_8n1(const format &f, int &c return desc; } -bool ccvf_format::load(io_generic *io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image *image) +bool ccvf_format::load(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image *image) { const format &f = formats[0]; - uint64_t size = io_generic_size(io); + uint64_t size; + if (io.length(size)) + return false; + std::vector<uint8_t> img(size); - io_generic_read(io, &img[0], 0, size); + size_t actual; + io.read_at(0, &img[0], size, actual); std::string ccvf = std::string((const char *)&img[0], size); std::vector<uint8_t> bytes(78720); |