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/d88_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/d88_dsk.cpp')
-rw-r--r-- | src/lib/formats/d88_dsk.cpp | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/lib/formats/d88_dsk.cpp b/src/lib/formats/d88_dsk.cpp index 7c4eaa079dc..6e29f10df6a 100644 --- a/src/lib/formats/d88_dsk.cpp +++ b/src/lib/formats/d88_dsk.cpp @@ -29,11 +29,12 @@ * */ - #include <cassert> - #include "flopimg.h" #include "imageutl.h" +#include "ioprocs.h" + + #define D88_HEADER_LEN 0x2b0 struct d88_tag @@ -414,12 +415,15 @@ const char *d88_format::extensions() const return "d77,d88,1dd"; } -int d88_format::identify(io_generic *io, uint32_t form_factor, const std::vector<uint32_t> &variants) +int d88_format::identify(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants) { - uint64_t size = io_generic_size(io); - uint8_t h[32]; + uint64_t size; + if(io.length(size)) + return 0; - io_generic_read(io, h, 0, 32); + uint8_t h[32]; + size_t actual; + io.read_at(0, h, 32, actual); if((little_endianize_int32(*(uint32_t *)(h+0x1c)) == size) && (h[0x1b] == 0x00 || h[0x1b] == 0x10 || h[0x1b] == 0x20 || h[0x1b] == 0x30 || h[0x1b] == 0x40)) return 100; @@ -427,11 +431,12 @@ int d88_format::identify(io_generic *io, uint32_t form_factor, const std::vector return 0; } -bool d88_format::load(io_generic *io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image *image) +bool d88_format::load(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants, floppy_image *image) { - uint8_t h[32]; + size_t actual; - io_generic_read(io, h, 0, 32); + uint8_t h[32]; + io.read_at(0, h, 32, actual); int cell_count = 0; int track_count = 0; @@ -477,9 +482,11 @@ bool d88_format::load(io_generic *io, uint32_t form_factor, const std::vector<ui return false; uint32_t track_pos[164]; - io_generic_read(io, track_pos, 32, 164*4); + io.read_at(32, track_pos, 164*4, actual); - uint64_t file_size = io_generic_size(io); + uint64_t file_size; + if(io.length(file_size)) + return false; for(int track=0; track < track_count; track++) for(int head=0; head < head_count; head++) { @@ -496,7 +503,7 @@ bool d88_format::load(io_generic *io, uint32_t form_factor, const std::vector<ui return true; uint8_t hs[16]; - io_generic_read(io, hs, pos, 16); + io.read_at(pos, hs, 16, actual); pos += 16; uint16_t size = little_endianize_int16(*(uint16_t *)(hs+14)); @@ -521,7 +528,7 @@ bool d88_format::load(io_generic *io, uint32_t form_factor, const std::vector<ui if(size) { sects[i].data = sect_data + sdatapos; - io_generic_read(io, sects[i].data, pos, size); + io.read_at(pos, sects[i].data, size, actual); pos += size; sdatapos += size; @@ -536,7 +543,7 @@ bool d88_format::load(io_generic *io, uint32_t form_factor, const std::vector<ui } -bool d88_format::save(io_generic *io, const std::vector<uint32_t> &variants, floppy_image *image) +bool d88_format::save(util::random_read_write &io, const std::vector<uint32_t> &variants, floppy_image *image) { return false; } |