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/ds9_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/ds9_dsk.cpp')
-rw-r--r-- | src/lib/formats/ds9_dsk.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/lib/formats/ds9_dsk.cpp b/src/lib/formats/ds9_dsk.cpp index fdf4f5e2299..c97a2cced51 100644 --- a/src/lib/formats/ds9_dsk.cpp +++ b/src/lib/formats/ds9_dsk.cpp @@ -14,10 +14,10 @@ ************************************************************************/ -#include <cassert> - #include "formats/ds9_dsk.h" +#include "ioprocs.h" + static FLOPPY_IDENTIFY(ds9_dsk_identify) { @@ -97,33 +97,32 @@ const char *ds9_format::extensions() const return "ds9"; } -void ds9_format::find_size(io_generic *io, uint8_t &track_count, uint8_t &head_count, uint8_t §or_count) +void ds9_format::find_size(util::random_read &io, uint8_t &track_count, uint8_t &head_count, uint8_t §or_count) { - uint32_t expected_size = 0; - uint64_t size = io_generic_size(io); - head_count = 2; track_count = 80; sector_count = 21; - expected_size = 256 * track_count * head_count * sector_count; + uint32_t const expected_size = 256 * track_count * head_count * sector_count; - if (size >= expected_size) // standard format has 860160 bytes + uint64_t size; + if (!io.length(size) && (size >= expected_size)) // standard format has 860160 bytes return; track_count = head_count = sector_count = 0; } -int ds9_format::identify(io_generic *io, uint32_t form_factor, const std::vector<uint32_t> &variants) +int ds9_format::identify(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants) { uint8_t track_count, head_count, sector_count; find_size(io, track_count, head_count, sector_count); - if (track_count) return 50; + if (track_count) + return 50; return 0; } -bool ds9_format::load(io_generic *io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image *image) +bool ds9_format::load(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image *image) { uint8_t track_count, head_count, sector_count; find_size(io, track_count, head_count, sector_count); @@ -143,7 +142,8 @@ bool ds9_format::load(io_generic *io, uint32_t form_factor, const std::vector<ui { for (int head = 0; head < head_count; head++) { - io_generic_read(io, sectdata, (track * head_count + head) * track_size, track_size); + size_t actual; + io.read_at((track * head_count + head) * track_size, sectdata, track_size, actual); generate_track(ds9_desc, track, head, sectors, sector_count, 104000, image); } } |