From e8bbea1fc6e94e14768509d322f6c624403ffb36 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sun, 22 Aug 2021 09:06:15 +1000 Subject: 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. --- src/lib/formats/os9_dsk.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/lib/formats/os9_dsk.cpp') diff --git a/src/lib/formats/os9_dsk.cpp b/src/lib/formats/os9_dsk.cpp index b28e4f8d293..ba1b2427811 100644 --- a/src/lib/formats/os9_dsk.cpp +++ b/src/lib/formats/os9_dsk.cpp @@ -48,6 +48,7 @@ #include "imageutl.h" #include "coretmpl.h" // BIT +#include "ioprocs.h" os9_format::os9_format() : wd177x_format(formats) @@ -69,21 +70,25 @@ const char *os9_format::extensions() const return "dsk,os9"; } -int os9_format::identify(io_generic *io, uint32_t form_factor, const std::vector &variants) +int os9_format::identify(util::random_read &io, uint32_t form_factor, const std::vector &variants) { - int type = find_size(io, form_factor, variants); + int const type = find_size(io, form_factor, variants); if (type != -1) return 75; + return 0; } -int os9_format::find_size(io_generic *io, uint32_t form_factor, const std::vector &variants) +int os9_format::find_size(util::random_read &io, uint32_t form_factor, const std::vector &variants) { - uint64_t size = io_generic_size(io); + uint64_t size; + if (io.length(size)) + return -1; uint8_t os9_header[0x60]; - io_generic_read(io, os9_header, 0, sizeof(os9_header)); + size_t actual; + io.read_at(0, os9_header, sizeof(os9_header), actual); int os9_total_sectors = pick_integer_be(os9_header, 0x00, 3); int os9_heads = util::BIT(os9_header[0x10], 0) ? 2 : 1; -- cgit v1.2.3-70-g09d2