summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/formats/flex_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/flex_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/flex_dsk.cpp')
-rw-r--r--src/lib/formats/flex_dsk.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/lib/formats/flex_dsk.cpp b/src/lib/formats/flex_dsk.cpp
index 692cc4bdc9d..4989a25e707 100644
--- a/src/lib/formats/flex_dsk.cpp
+++ b/src/lib/formats/flex_dsk.cpp
@@ -50,7 +50,11 @@
*/
#include "flex_dsk.h"
-#include "formats/imageutl.h"
+
+#include "imageutl.h"
+
+#include "ioprocs.h"
+
flex_format::flex_format() : wd177x_format(formats)
{
@@ -71,7 +75,7 @@ const char *flex_format::extensions() const
return "dsk";
}
-int flex_format::identify(io_generic *io, uint32_t form_factor, const std::vector<uint32_t> &variants)
+int flex_format::identify(util::random_read &io, uint32_t form_factor, const std::vector<uint32_t> &variants)
{
int type = find_size(io, form_factor, variants);
@@ -80,17 +84,21 @@ int flex_format::identify(io_generic *io, uint32_t form_factor, const std::vecto
return 0;
}
-int flex_format::find_size(io_generic *io, uint32_t form_factor, const std::vector<uint32_t> &variants)
+int flex_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 boot0[256], boot1[256];
+ size_t actual;
// Look at the boot sector.
// Density, sides, link??
- io_generic_read(io, &boot0, 256 * 0, sizeof(boot0));
- io_generic_read(io, &boot1, 256 * 1, sizeof(boot1));
+ io.read_at(256 * 0, &boot0, sizeof(boot0), actual);
+ io.read_at(256 * 1, &boot1, sizeof(boot1), actual);
// Look at the system information sector.
- io_generic_read(io, &info, 256 * 2, sizeof(struct sysinfo_sector));
+ io.read_at(256 * 2, &info, sizeof(struct sysinfo_sector), actual);
LOG_FORMATS("FLEX floppy dsk: size %d bytes, %d total sectors, %d remaining bytes, expected form factor %x\n", (uint32_t)size, (uint32_t)size / 256, (uint32_t)size % 256, form_factor);