mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Flux sink type is now detected from file extension.
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
#include "dataspec.h"
|
||||
#include "fluxsink/fluxsink.h"
|
||||
#include "lib/config.pb.h"
|
||||
#include "proto.h"
|
||||
#include "utils.h"
|
||||
#include "fmt/format.h"
|
||||
|
||||
std::unique_ptr<FluxSink> FluxSink::create(const FluxSinkProto& config)
|
||||
{
|
||||
@@ -27,3 +30,28 @@ std::unique_ptr<FluxSink> FluxSink::create(const FluxSinkProto& config)
|
||||
Error() << "bad output disk config";
|
||||
return std::unique_ptr<FluxSink>();
|
||||
}
|
||||
|
||||
void FluxSink::updateConfigForFilename(const std::string& filename)
|
||||
{
|
||||
FluxSinkProto* f = config.mutable_output()->mutable_flux();
|
||||
static const std::map<std::string, std::function<void(void)>> formats =
|
||||
{
|
||||
{".flux", [&]() { f->set_fluxfile(filename); }},
|
||||
{".scp", [&]() { f->mutable_scp()->set_filename(filename); }},
|
||||
{".vcd", [&]() { f->mutable_vcd()->set_directory(filename); }},
|
||||
{".au", [&]() { f->mutable_au()->set_directory(filename); }},
|
||||
};
|
||||
|
||||
for (const auto& it : formats)
|
||||
{
|
||||
if (endsWith(filename, it.first))
|
||||
{
|
||||
it.second();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Error() << fmt::format("unrecognised flux filename '{}'", filename);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
static std::unique_ptr<FluxSink> createScpFluxSink(const ScpFluxSinkProto& config);
|
||||
|
||||
static std::unique_ptr<FluxSink> create(const FluxSinkProto& config);
|
||||
static void updateConfigForFilename(const std::string& filename);
|
||||
|
||||
public:
|
||||
virtual void writeFlux(int track, int side, Fluxmap& fluxmap) = 0;
|
||||
|
||||
@@ -44,7 +44,7 @@ static StringFlag destFlux(
|
||||
"",
|
||||
[](const auto& value)
|
||||
{
|
||||
config.mutable_output()->mutable_flux()->set_fluxfile(value);
|
||||
FluxSink::updateConfigForFilename(value);
|
||||
});
|
||||
|
||||
static StringFlag auFile(
|
||||
@@ -65,15 +65,6 @@ static StringFlag vcdFile(
|
||||
config.mutable_output()->mutable_flux()->mutable_vcd()->set_directory(value);
|
||||
});
|
||||
|
||||
static StringFlag scpFile(
|
||||
{ "--scp" },
|
||||
"write destination flux to this .scp file",
|
||||
"",
|
||||
[](const auto& value)
|
||||
{
|
||||
config.mutable_output()->mutable_flux()->mutable_scp()->set_filename(value);
|
||||
});
|
||||
|
||||
static StringFlag srcCylinders(
|
||||
{ "--cylinders", "-c" },
|
||||
"cylinders to read from",
|
||||
|
||||
@@ -30,7 +30,7 @@ static StringFlag destFlux(
|
||||
"",
|
||||
[](const auto& value)
|
||||
{
|
||||
config.mutable_output()->mutable_flux()->set_fluxfile(value);
|
||||
FluxSink::updateConfigForFilename(value);
|
||||
});
|
||||
|
||||
static IntFlag destDrive(
|
||||
|
||||
@@ -34,7 +34,7 @@ static StringFlag destFlux(
|
||||
"",
|
||||
[](const auto& value)
|
||||
{
|
||||
config.mutable_output()->mutable_flux()->set_fluxfile(value);
|
||||
FluxSink::updateConfigForFilename(value);
|
||||
});
|
||||
|
||||
static IntFlag destDrive(
|
||||
|
||||
Reference in New Issue
Block a user