From a6b2e932faabc770b843c8ed20bc4d70abd756be Mon Sep 17 00:00:00 2001 From: David Given Date: Tue, 18 May 2021 20:13:03 +0200 Subject: [PATCH] copy-flux-to works. --- lib/decoders/decoders.proto | 5 +++-- lib/reader.cc | 4 +++- src/fe-read.cc | 13 +++++++++++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/decoders/decoders.proto b/lib/decoders/decoders.proto index 45867238..4efc0615 100644 --- a/lib/decoders/decoders.proto +++ b/lib/decoders/decoders.proto @@ -14,6 +14,7 @@ import "arch/mx/mx.proto"; import "arch/tids990/tids990.proto"; import "arch/victor9k/victor9k.proto"; import "arch/zilogmcz/zilogmcz.proto"; +import "lib/fluxsink/fluxsink.proto"; import "lib/common.proto"; message DecoderProto { @@ -43,8 +44,8 @@ message DecoderProto { ZilogMczDecoderProto zilogmcz = 18; } - optional string copy_flux_to = 19 - [(help) = "while decoding, write a copy of the flux to this file"]; + optional FluxSinkProto copy_flux_to = 19 + [(help) = "while decoding, write a copy of the flux here"]; optional bool dump_records = 20 [default = false, (help) = "if set, then dump the parsed but undecoded disk records"]; optional bool dump_sectors = 21 [default = false, diff --git a/lib/reader.cc b/lib/reader.cc index 17fc84d0..5bf3fca6 100644 --- a/lib/reader.cc +++ b/lib/reader.cc @@ -65,6 +65,8 @@ static void replace_sector(std::unique_ptr& replacing, Sector& replaceme void readDiskCommand(FluxSource& fluxsource, AbstractDecoder& decoder, ImageWriter& writer) { + outputFluxSink = FluxSink::create(config.decoder().copy_flux_to()); + bool failures = false; SectorSet allSectors; for (int cylinder : iterate(config.cylinders())) @@ -185,7 +187,7 @@ void readDiskCommand(FluxSource& fluxsource, AbstractDecoder& decoder, ImageWrit } writer.printMap(allSectors); - if (!config.decoder().has_write_csv_to()) + if (config.decoder().has_write_csv_to()) writer.writeCsv(allSectors, config.decoder().write_csv_to()); writer.writeImage(allSectors); diff --git a/src/fe-read.cc b/src/fe-read.cc index c03f7ffd..31784733 100644 --- a/src/fe-read.cc +++ b/src/fe-read.cc @@ -10,6 +10,7 @@ #include "proto.h" #include "dataspec.h" #include "fluxsource/fluxsource.h" +#include "fluxsink/fluxsink.h" #include "arch/brother/brother.h" #include "arch/ibm/ibm.h" #include "imagewriter/imagewriter.h" @@ -46,6 +47,15 @@ static StringFlag destImage( ImageWriter::updateConfigForFilename(config.mutable_output()->mutable_image(), value); }); +static StringFlag copyFluxTo( + { "--copy-flux-to" }, + "while reading, copy the read flux to this file", + "", + [](const auto& value) + { + FluxSink::updateConfigForFilename(config.mutable_decoder()->mutable_copy_flux_to(), value); + }); + static StringFlag srcCylinders( { "--cylinders", "-c" }, "cylinders to read from", @@ -73,6 +83,9 @@ int mainRead(int argc, const char* argv[]) if (!config.input().has_flux() || !config.output().has_image()) Error() << "incomplete config (did you remember to specify the format?)"; + if (config.decoder().copy_flux_to().has_drive()) + Error() << "you cannot copy flux to a hardware device"; + std::unique_ptr fluxSource(FluxSource::create(config.input().flux())); std::unique_ptr decoder(AbstractDecoder::create(config.decoder())); std::unique_ptr writer(ImageWriter::create(config.output().image()));