mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Add helper flags to fe-read and fe-write for setting common parameters.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include "imagereader/imagereader.h"
|
||||
#include "utils.h"
|
||||
#include "fmt/format.h"
|
||||
#include "proto.h"
|
||||
#include "lib/config.pb.h"
|
||||
#include <algorithm>
|
||||
#include <ctype.h>
|
||||
@@ -31,6 +32,32 @@ std::unique_ptr<ImageReader> ImageReader::create(const InputFileProto& config)
|
||||
return std::unique_ptr<ImageReader>();
|
||||
}
|
||||
|
||||
void ImageReader::updateConfigForFilename(const std::string& filename)
|
||||
{
|
||||
InputFileProto* f = config.mutable_input()->mutable_file();
|
||||
static const std::map<std::string, std::function<void(void)>> formats =
|
||||
{
|
||||
{".adf", [&]() { f->mutable_img(); }},
|
||||
{".jv3", [&]() { f->mutable_jv3(); }},
|
||||
{".d81", [&]() { f->mutable_img(); }},
|
||||
{".diskcopy", [&]() { f->mutable_diskcopy(); }},
|
||||
{".img", [&]() { f->mutable_img(); }},
|
||||
{".st", [&]() { f->mutable_img(); }},
|
||||
};
|
||||
|
||||
for (const auto& it : formats)
|
||||
{
|
||||
if (endsWith(filename, it.first))
|
||||
{
|
||||
it.second();
|
||||
f->set_filename(filename);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Error() << fmt::format("unrecognised image filename '{}'", filename);
|
||||
}
|
||||
|
||||
ImageReader::ImageReader(const InputFileProto& config):
|
||||
_config(config)
|
||||
{}
|
||||
|
||||
Reference in New Issue
Block a user