Files
fluxengine/src/fe-rawread.cc
David Given 088bd9434d Switch from using a oneof to an explicit enum for the flux source/sink
configurations, as this allows default options for multiple source/sink types.
2022-11-19 22:52:52 +01:00

78 lines
1.8 KiB
C++

#include "globals.h"
#include "flags.h"
#include "readerwriter.h"
#include "fluxmap.h"
#include "decoders/decoders.h"
#include "macintosh/macintosh.h"
#include "sector.h"
#include "proto.h"
#include "fluxsink/fluxsink.h"
#include "fluxsource/fluxsource.h"
#include "arch/brother/brother.h"
#include "arch/ibm/ibm.h"
#include "imagewriter/imagewriter.h"
#include "fmt/format.h"
#include "fluxengine.h"
#include <google/protobuf/text_format.h>
#include <fstream>
static FlagGroup flags;
static StringFlag sourceFlux(
{ "-s", "--source" },
"flux file to read from",
"",
[](const auto& value)
{
FluxSource::updateConfigForFilename(config.mutable_flux_source(), value);
});
static StringFlag destFlux(
{ "-d", "--dest" },
"destination flux file to write to",
"",
[](const auto& value)
{
FluxSink::updateConfigForFilename(config.mutable_flux_sink(), value);
});
static StringFlag srcTracks(
{ "--cylinders", "-c" },
"tracks to read from",
"",
[](const auto& value)
{
setRange(config.mutable_tracks(), value);
});
static StringFlag srcHeads(
{ "--heads", "-h" },
"heads to read from",
"",
[](const auto& value)
{
setRange(config.mutable_heads(), value);
});
int mainRawRead(int argc, const char* argv[])
{
setRange(config.mutable_tracks(), "0-79");
setRange(config.mutable_heads(), "0-1");
if (argc == 1)
showProfiles("rawread", formats);
config.mutable_flux_source()->set_type(FluxSourceProto::DRIVE);
flags.parseFlagsWithConfigFiles(argc, argv, formats);
if (config.flux_sink().type() == FluxSinkProto::DRIVE)
Error() << "you can't use rawread to write to hardware";
std::unique_ptr<FluxSource> fluxSource(FluxSource::create(config.flux_source()));
std::unique_ptr<FluxSink> fluxSink(FluxSink::create(config.flux_sink()));
rawReadDiskCommand(*fluxSource, *fluxSink);
return 0;
}