summaryrefslogtreecommitdiffstats
path: root/src/lib/formats/os9_dsk.cpp
diff options
context:
space:
mode:
author Vas Crabb <cuavas@users.noreply.github.com>2021-08-22 09:06:15 +1000
committer GitHub <noreply@github.com>2021-08-22 09:06:15 +1000
commite8bbea1fc6e94e14768509d322f6c624403ffb36 (patch)
tree74dd1606a900d83de8aecff17a6737af4113308d /src/lib/formats/os9_dsk.cpp
parente319bde5fc3696d7f48f62b15b6366c4377fe5d1 (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/os9_dsk.cpp')
-rw-r--r--src/lib/formats/os9_dsk.cpp15
1 files changed, 10 insertions, 5 deletions
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<uint32_t> &variants)
+int os9_format::identify(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &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<uint32_t> &variants)
+int os9_format::find_size(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &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;