Merge pull request #697 from davidgiven/ro

Allow read-only flux and image in the GUI.
This commit is contained in:
David Given
2023-07-24 08:20:39 +02:00
committed by GitHub
52 changed files with 361 additions and 319 deletions

View File

@@ -19,4 +19,36 @@ enum IndexMode {
INDEXMODE_360 = 2;
}
enum FluxSourceSinkType {
FLUXTYPE_NOT_SET = 0;
FLUXTYPE_A2R = 1;
FLUXTYPE_AU = 2;
FLUXTYPE_CWF = 3;
FLUXTYPE_DRIVE = 4;
FLUXTYPE_ERASE = 5;
FLUXTYPE_FLUX = 6;
FLUXTYPE_FLX = 7;
FLUXTYPE_KRYOFLUX = 8;
FLUXTYPE_SCP = 9;
FLUXTYPE_TEST_PATTERN = 10;
FLUXTYPE_VCD = 11;
}
enum ImageReaderWriterType {
IMAGETYPE_NOT_SET = 0;
IMAGETYPE_D64 = 1;
IMAGETYPE_D88 = 2;
IMAGETYPE_DIM = 3;
IMAGETYPE_DISKCOPY = 4;
IMAGETYPE_FDI = 5;
IMAGETYPE_IMD = 6;
IMAGETYPE_IMG = 7;
IMAGETYPE_JV3 = 8;
IMAGETYPE_LDBS = 9;
IMAGETYPE_NFD = 10;
IMAGETYPE_NSI = 11;
IMAGETYPE_RAW = 12;
IMAGETYPE_TD0 = 13;
}

View File

@@ -15,6 +15,148 @@
static Config config;
struct FluxConstructor
{
std::regex pattern;
std::function<void(const std::string& filename, FluxSourceProto*)> source;
std::function<void(const std::string& filename, FluxSinkProto*)> sink;
};
enum ConstructorMode
{
MODE_RO,
MODE_WO,
MODE_RW
};
struct ImageConstructor
{
std::string extension;
ImageReaderWriterType type;
ConstructorMode mode;
};
static const std::vector<FluxConstructor> fluxConstructors = {
{.pattern = std::regex("^(.*\\.flux)$"),
.source =
[](auto& s, auto* proto)
{
proto->set_type(FLUXTYPE_FLUX);
proto->mutable_fl2()->set_filename(s);
}, .sink =
[](auto& s, auto* proto)
{
proto->set_type(FLUXTYPE_FLUX);
proto->mutable_fl2()->set_filename(s);
}},
{
.pattern = std::regex("^(.*\\.scp)$"),
.source =
[](auto& s, auto* proto)
{
proto->set_type(FLUXTYPE_SCP);
proto->mutable_scp()->set_filename(s);
}, .sink =
[](auto& s, auto* proto)
{
proto->set_type(FLUXTYPE_SCP);
proto->mutable_scp()->set_filename(s);
}, },
{.pattern = std::regex("^(.*\\.a2r)$"),
.source =
[](auto& s, auto* proto)
{
proto->set_type(FLUXTYPE_A2R);
proto->mutable_a2r()->set_filename(s);
}, .sink =
[](auto& s, auto* proto)
{
proto->set_type(FLUXTYPE_A2R);
proto->mutable_a2r()->set_filename(s);
}},
{.pattern = std::regex("^(.*\\.cwf)$"),
.source =
[](auto& s, auto* proto)
{
proto->set_type(FLUXTYPE_CWF);
proto->mutable_cwf()->set_filename(s);
}},
{.pattern = std::regex("^erase:$"),
.source =
[](auto& s, auto* proto)
{
proto->set_type(FLUXTYPE_ERASE);
}},
{.pattern = std::regex("^kryoflux:(.*)$"),
.source =
[](auto& s, auto* proto)
{
proto->set_type(FLUXTYPE_KRYOFLUX);
proto->mutable_kryoflux()->set_directory(s);
}},
{.pattern = std::regex("^testpattern:(.*)"),
.source =
[](auto& s, auto* proto)
{
proto->set_type(FLUXTYPE_TEST_PATTERN);
}},
{.pattern = std::regex("^drive:(.*)"),
.source =
[](auto& s, auto* proto)
{
proto->set_type(FLUXTYPE_DRIVE);
globalConfig().overrides()->mutable_drive()->set_drive(
std::stoi(s));
}, .sink =
[](auto& s, auto* proto)
{
proto->set_type(FLUXTYPE_DRIVE);
globalConfig().overrides()->mutable_drive()->set_drive(
std::stoi(s));
}},
{.pattern = std::regex("^flx:(.*)$"),
.source =
[](auto& s, auto* proto)
{
proto->set_type(FLUXTYPE_FLX);
proto->mutable_flx()->set_directory(s);
}},
{.pattern = std::regex("^vcd:(.*)$"),
.sink =
[](auto& s, auto* proto)
{
proto->set_type(FLUXTYPE_VCD);
proto->mutable_vcd()->set_directory(s);
}},
{.pattern = std::regex("^au:(.*)$"),
.sink =
[](auto& s, auto* proto)
{
proto->set_type(FLUXTYPE_AU);
proto->mutable_au()->set_directory(s);
}},
};
static const std::vector<ImageConstructor> imageConstructors = {
{".adf", IMAGETYPE_IMG, MODE_RW},
{".d64", IMAGETYPE_D64, MODE_RW},
{".d81", IMAGETYPE_IMG, MODE_RW},
{".d88", IMAGETYPE_D88, MODE_RW},
{".dim", IMAGETYPE_DIM, MODE_RO},
{".diskcopy", IMAGETYPE_DISKCOPY, MODE_RW},
{".dsk", IMAGETYPE_IMG, MODE_RW},
{".fdi", IMAGETYPE_FDI, MODE_RO},
{".imd", IMAGETYPE_IMD, MODE_RW},
{".img", IMAGETYPE_IMG, MODE_RW},
{".jv3", IMAGETYPE_JV3, MODE_RO},
{".nfd", IMAGETYPE_NFD, MODE_RO},
{".nsi", IMAGETYPE_NSI, MODE_RW},
{".st", IMAGETYPE_IMG, MODE_RW},
{".td0", IMAGETYPE_TD0, MODE_RO},
{".vgi", IMAGETYPE_IMG, MODE_RW},
{".xdf", IMAGETYPE_IMG, MODE_RW},
};
Config& globalConfig()
{
return config;
@@ -334,72 +476,17 @@ void Config::clearOptions()
invalidate();
}
static void setFluxSourceImpl(std::string filename, FluxSourceProto* proto)
static void setFluxSourceImpl(
const std::string& filename, FluxSourceProto* proto)
{
static const std::vector<std::pair<std::regex,
std::function<void(const std::string&, FluxSourceProto*)>>>
formats = {
{std::regex("^(.*\\.flux)$"),
[](auto& s, auto* proto)
{
proto->set_type(FluxSourceProto::FLUX);
proto->mutable_fl2()->set_filename(s);
}},
{std::regex("^(.*\\.scp)$"),
[](auto& s, auto* proto)
{
proto->set_type(FluxSourceProto::SCP);
proto->mutable_scp()->set_filename(s);
}},
{std::regex("^(.*\\.a2r)$"),
[](auto& s, auto* proto)
{
proto->set_type(FluxSourceProto::A2R);
proto->mutable_a2r()->set_filename(s);
}},
{std::regex("^(.*\\.cwf)$"),
[](auto& s, auto* proto)
{
proto->set_type(FluxSourceProto::CWF);
proto->mutable_cwf()->set_filename(s);
}},
{std::regex("^erase:$"),
[](auto& s, auto* proto)
{
proto->set_type(FluxSourceProto::ERASE);
}},
{std::regex("^kryoflux:(.*)$"),
[](auto& s, auto* proto)
{
proto->set_type(FluxSourceProto::KRYOFLUX);
proto->mutable_kryoflux()->set_directory(s);
}},
{std::regex("^testpattern:(.*)"),
[](auto& s, auto* proto)
{
proto->set_type(FluxSourceProto::TEST_PATTERN);
}},
{std::regex("^drive:(.*)"),
[](auto& s, auto* proto)
{
proto->set_type(FluxSourceProto::DRIVE);
globalConfig().overrides()->mutable_drive()->set_drive(
std::stoi(s));
}},
{std::regex("^flx:(.*)$"),
[](auto& s, auto* proto)
{
proto->set_type(FluxSourceProto::FLX);
proto->mutable_flx()->set_directory(s);
}},
};
for (const auto& it : formats)
for (const auto& it : fluxConstructors)
{
std::smatch match;
if (std::regex_match(filename, match, it.first))
if (std::regex_match(filename, match, it.pattern))
{
it.second(match[1], proto);
if (!it.source)
throw new InapplicableValueException();
it.source(match[1], proto);
return;
}
}
@@ -412,56 +499,16 @@ void Config::setFluxSource(std::string filename)
setFluxSourceImpl(filename, overrides()->mutable_flux_source());
}
static void setFluxSinkImpl(std::string filename, FluxSinkProto* proto)
static void setFluxSinkImpl(const std::string& filename, FluxSinkProto* proto)
{
static const std::vector<std::pair<std::regex,
std::function<void(const std::string&, FluxSinkProto*)>>>
formats = {
{std::regex("^(.*\\.a2r)$"),
[](auto& s, auto* proto)
{
proto->set_type(FluxSinkProto::A2R);
proto->mutable_a2r()->set_filename(s);
}},
{std::regex("^(.*\\.flux)$"),
[](auto& s, auto* proto)
{
proto->set_type(FluxSinkProto::FLUX);
proto->mutable_fl2()->set_filename(s);
}},
{std::regex("^(.*\\.scp)$"),
[](auto& s, auto* proto)
{
proto->set_type(FluxSinkProto::SCP);
proto->mutable_scp()->set_filename(s);
}},
{std::regex("^vcd:(.*)$"),
[](auto& s, auto* proto)
{
proto->set_type(FluxSinkProto::VCD);
proto->mutable_vcd()->set_directory(s);
}},
{std::regex("^au:(.*)$"),
[](auto& s, auto* proto)
{
proto->set_type(FluxSinkProto::AU);
proto->mutable_au()->set_directory(s);
}},
{std::regex("^drive:(.*)"),
[](auto& s, auto* proto)
{
proto->set_type(FluxSinkProto::DRIVE);
globalConfig().overrides()->mutable_drive()->set_drive(
std::stoi(s));
}},
};
for (const auto& it : formats)
for (const auto& it : fluxConstructors)
{
std::smatch match;
if (std::regex_match(filename, match, it.first))
if (std::regex_match(filename, match, it.pattern))
{
it.second(match[1], proto);
if (!it.sink)
throw new InapplicableValueException();
it.sink(match[1], proto);
return;
}
}
@@ -487,34 +534,14 @@ void Config::setVerificationFluxSource(std::string filename)
void Config::setImageReader(std::string filename)
{
static const std::map<std::string, std::function<void(ImageReaderProto*)>>
formats = {
// clang-format off
{".adf", [](auto* proto) { proto->set_type(ImageReaderProto::IMG); }},
{".d64", [](auto* proto) { proto->set_type(ImageReaderProto::D64); }},
{".d81", [](auto* proto) { proto->set_type(ImageReaderProto::IMG); }},
{".d88", [](auto* proto) { proto->set_type(ImageReaderProto::D88); }},
{".dim", [](auto* proto) { proto->set_type(ImageReaderProto::DIM); }},
{".diskcopy", [](auto* proto) { proto->set_type(ImageReaderProto::DISKCOPY); }},
{".dsk", [](auto* proto) { proto->set_type(ImageReaderProto::IMG); }},
{".fdi", [](auto* proto) { proto->set_type(ImageReaderProto::FDI); }},
{".imd", [](auto* proto) { proto->set_type(ImageReaderProto::IMD); }},
{".img", [](auto* proto) { proto->set_type(ImageReaderProto::IMG); }},
{".jv3", [](auto* proto) { proto->set_type(ImageReaderProto::JV3); }},
{".nfd", [](auto* proto) { proto->set_type(ImageReaderProto::NFD); }},
{".nsi", [](auto* proto) { proto->set_type(ImageReaderProto::NSI); }},
{".st", [](auto* proto) { proto->set_type(ImageReaderProto::IMG); }},
{".td0", [](auto* proto) { proto->set_type(ImageReaderProto::TD0); }},
{".vgi", [](auto* proto) { proto->set_type(ImageReaderProto::IMG); }},
{".xdf", [](auto* proto) { proto->set_type(ImageReaderProto::IMG); }},
// clang-format on
};
for (const auto& it : formats)
for (const auto& it : imageConstructors)
{
if (endsWith(filename, it.first))
if (endsWith(filename, it.extension))
{
it.second(overrides()->mutable_image_reader());
if (it.mode == MODE_WO)
throw new InapplicableValueException();
overrides()->mutable_image_reader()->set_type(it.type);
overrides()->mutable_image_reader()->set_filename(filename);
return;
}
@@ -525,31 +552,14 @@ void Config::setImageReader(std::string filename)
void Config::setImageWriter(std::string filename)
{
static const std::map<std::string, std::function<void(ImageWriterProto*)>>
formats = {
// clang-format off
{".adf", [](auto* proto) { proto->set_type(ImageWriterProto::IMG); }},
{".d64", [](auto* proto) { proto->set_type(ImageWriterProto::D64); }},
{".d81", [](auto* proto) { proto->set_type(ImageWriterProto::IMG); }},
{".d88", [](auto* proto) { proto->set_type(ImageWriterProto::D88); }},
{".diskcopy", [](auto* proto) { proto->set_type(ImageWriterProto::DISKCOPY); }},
{".dsk", [](auto* proto) { proto->set_type(ImageWriterProto::IMG); }},
{".img", [](auto* proto) { proto->set_type(ImageWriterProto::IMG); }},
{".imd", [](auto* proto) { proto->set_type(ImageWriterProto::IMD); }},
{".ldbs", [](auto* proto) { proto->set_type(ImageWriterProto::LDBS); }},
{".nsi", [](auto* proto) { proto->set_type(ImageWriterProto::NSI); }},
{".raw", [](auto* proto) { proto->set_type(ImageWriterProto::RAW); }},
{".st", [](auto* proto) { proto->set_type(ImageWriterProto::IMG); }},
{".vgi", [](auto* proto) { proto->set_type(ImageWriterProto::IMG); }},
{".xdf", [](auto* proto) { proto->set_type(ImageWriterProto::IMG); }},
// clang-format on
};
for (const auto& it : formats)
for (const auto& it : imageConstructors)
{
if (endsWith(filename, it.first))
if (endsWith(filename, it.extension))
{
it.second(overrides()->mutable_image_writer());
if (it.mode == MODE_RO)
throw new InapplicableValueException();
overrides()->mutable_image_writer()->set_type(it.type);
overrides()->mutable_image_writer()->set_filename(filename);
return;
}
@@ -560,7 +570,7 @@ void Config::setImageWriter(std::string filename)
bool Config::hasFluxSource()
{
return (*this)->flux_source().type() != FluxSourceProto::NOT_SET;
return (*this)->flux_source().type() != FLUXTYPE_NOT_SET;
}
std::shared_ptr<FluxSource>& Config::getFluxSource()
@@ -578,7 +588,7 @@ std::shared_ptr<FluxSource>& Config::getFluxSource()
bool Config::hasVerificationFluxSource() const
{
return _verificationFluxSourceProto.type() != FluxSourceProto::NOT_SET;
return _verificationFluxSourceProto.type() != FLUXTYPE_NOT_SET;
}
std::shared_ptr<FluxSource>& Config::getVerificationFluxSource()
@@ -596,7 +606,7 @@ std::shared_ptr<FluxSource>& Config::getVerificationFluxSource()
bool Config::hasImageReader()
{
return (*this)->image_reader().type() != ImageReaderProto::NOT_SET;
return (*this)->image_reader().type() != IMAGETYPE_NOT_SET;
}
std::shared_ptr<ImageReader>& Config::getImageReader()
@@ -614,7 +624,7 @@ std::shared_ptr<ImageReader>& Config::getImageReader()
bool Config::hasFluxSink()
{
return (*this)->flux_sink().type() != FluxSinkProto::NOT_SET;
return (*this)->flux_sink().type() != FLUXTYPE_NOT_SET;
}
std::unique_ptr<FluxSink> Config::getFluxSink()
@@ -627,7 +637,7 @@ std::unique_ptr<FluxSink> Config::getFluxSink()
bool Config::hasImageWriter()
{
return (*this)->image_writer().type() != ImageWriterProto::NOT_SET;
return (*this)->image_writer().type() != IMAGETYPE_NOT_SET;
}
std::unique_ptr<ImageWriter> Config::getImageWriter()

View File

@@ -4,6 +4,7 @@
#include <google/protobuf/message.h>
#include "lib/config.pb.h"
#include "lib/common.pb.h"
class ConfigProto;
class OptionProto;
@@ -46,6 +47,14 @@ public:
}
};
class InapplicableValueException : public ErrorException
{
public:
InapplicableValueException():
ErrorException("selected format cannot be used here")
{}
};
class Config
{
public:

View File

@@ -10,26 +10,25 @@ std::unique_ptr<FluxSink> FluxSink::create(const FluxSinkProto& config)
{
switch (config.type())
{
case FluxSinkProto::DRIVE:
case FLUXTYPE_DRIVE:
return createHardwareFluxSink(config.drive());
case FluxSinkProto::A2R:
case FLUXTYPE_A2R:
return createA2RFluxSink(config.a2r());
case FluxSinkProto::AU:
case FLUXTYPE_AU:
return createAuFluxSink(config.au());
case FluxSinkProto::VCD:
case FLUXTYPE_VCD:
return createVcdFluxSink(config.vcd());
case FluxSinkProto::SCP:
case FLUXTYPE_SCP:
return createScpFluxSink(config.scp());
case FluxSinkProto::FLUX:
case FLUXTYPE_FLUX:
return createFl2FluxSink(config.fl2());
default:
error("bad output disk config");
return std::unique_ptr<FluxSink>();
}
}

View File

@@ -29,17 +29,8 @@ message Fl2FluxSinkProto {
// Next: 10
message FluxSinkProto {
enum FluxSinkType {
NOT_SET = 0;
DRIVE = 1;
A2R = 2;
AU = 3;
VCD = 4;
SCP = 5;
FLUX = 6;
}
optional FluxSinkType type = 9 [default = NOT_SET, (help) = "flux sink type"];
optional FluxSourceSinkType type = 9
[default = FLUXTYPE_NOT_SET, (help) = "flux sink type"];
optional HardwareFluxSinkProto drive = 2;
optional A2RFluxSinkProto a2r = 8;

View File

@@ -10,35 +10,34 @@ std::unique_ptr<FluxSource> FluxSource::create(const FluxSourceProto& config)
{
switch (config.type())
{
case FluxSourceProto::DRIVE:
case FLUXTYPE_DRIVE:
return createHardwareFluxSource(config.drive());
case FluxSourceProto::ERASE:
case FLUXTYPE_ERASE:
return createEraseFluxSource(config.erase());
case FluxSourceProto::KRYOFLUX:
case FLUXTYPE_KRYOFLUX:
return createKryofluxFluxSource(config.kryoflux());
case FluxSourceProto::TEST_PATTERN:
case FLUXTYPE_TEST_PATTERN:
return createTestPatternFluxSource(config.test_pattern());
case FluxSourceProto::SCP:
case FLUXTYPE_SCP:
return createScpFluxSource(config.scp());
case FluxSourceProto::A2R:
case FLUXTYPE_A2R:
return createA2rFluxSource(config.a2r());
case FluxSourceProto::CWF:
case FLUXTYPE_CWF:
return createCwfFluxSource(config.cwf());
case FluxSourceProto::FLUX:
case FLUXTYPE_FLUX:
return createFl2FluxSource(config.fl2());
case FluxSourceProto::FLX:
case FLUXTYPE_FLX:
return createFlxFluxSource(config.flx());
default:
error("bad input disk configuration");
return std::unique_ptr<FluxSource>();
}
}

View File

@@ -41,20 +41,8 @@ message FlxFluxSourceProto {
// NEXT: 12
message FluxSourceProto {
enum FluxSourceType {
NOT_SET = 0;
DRIVE = 1;
TEST_PATTERN = 2;
ERASE = 3;
KRYOFLUX = 4;
SCP = 5;
CWF = 6;
FLUX = 7;
FLX = 8;
A2R = 9;
}
optional FluxSourceType type = 9 [default = NOT_SET, (help) = "flux source type"];
optional FluxSourceSinkType type = 9
[default = FLUXTYPE_NOT_SET, (help) = "flux source type"];
optional A2rFluxSourceProto a2r = 11;
optional CwfFluxSourceProto cwf = 7;

View File

@@ -15,37 +15,37 @@ std::unique_ptr<ImageReader> ImageReader::create(const ImageReaderProto& config)
{
switch (config.type())
{
case ImageReaderProto::DIM:
case IMAGETYPE_DIM:
return ImageReader::createDimImageReader(config);
case ImageReaderProto::D88:
case IMAGETYPE_D88:
return ImageReader::createD88ImageReader(config);
case ImageReaderProto::FDI:
case IMAGETYPE_FDI:
return ImageReader::createFdiImageReader(config);
case ImageReaderProto::IMD:
case IMAGETYPE_IMD:
return ImageReader::createIMDImageReader(config);
case ImageReaderProto::IMG:
case IMAGETYPE_IMG:
return ImageReader::createImgImageReader(config);
case ImageReaderProto::DISKCOPY:
case IMAGETYPE_DISKCOPY:
return ImageReader::createDiskCopyImageReader(config);
case ImageReaderProto::JV3:
case IMAGETYPE_JV3:
return ImageReader::createJv3ImageReader(config);
case ImageReaderProto::D64:
case IMAGETYPE_D64:
return ImageReader::createD64ImageReader(config);
case ImageReaderProto::NFD:
case IMAGETYPE_NFD:
return ImageReader::createNFDImageReader(config);
case ImageReaderProto::NSI:
case IMAGETYPE_NSI:
return ImageReader::createNsiImageReader(config);
case ImageReaderProto::TD0:
case IMAGETYPE_TD0:
return ImageReader::createTd0ImageReader(config);
default:

View File

@@ -24,22 +24,8 @@ message ImageReaderProto
default = false
];
enum ImageReaderType {
NOT_SET = 0;
IMG = 1;
DISKCOPY = 2;
IMD = 3;
JV3 = 4;
D64 = 5;
NSI = 6;
TD0 = 7;
DIM = 8;
FDI = 9;
D88 = 10;
NFD = 11;
}
optional ImageReaderType type = 14 [default = NOT_SET, (help) = "input image type"];
optional ImageReaderWriterType type = 14
[default = IMAGETYPE_NOT_SET, (help) = "input image type"];
optional ImgInputOutputProto img = 2;
optional DiskCopyInputProto diskcopy = 3;

View File

@@ -15,28 +15,28 @@ std::unique_ptr<ImageWriter> ImageWriter::create(const ImageWriterProto& config)
{
switch (config.type())
{
case ImageWriterProto::IMG:
case IMAGETYPE_IMG:
return ImageWriter::createImgImageWriter(config);
case ImageWriterProto::D64:
case IMAGETYPE_D64:
return ImageWriter::createD64ImageWriter(config);
case ImageWriterProto::LDBS:
case IMAGETYPE_LDBS:
return ImageWriter::createLDBSImageWriter(config);
case ImageWriterProto::DISKCOPY:
case IMAGETYPE_DISKCOPY:
return ImageWriter::createDiskCopyImageWriter(config);
case ImageWriterProto::NSI:
case IMAGETYPE_NSI:
return ImageWriter::createNsiImageWriter(config);
case ImageWriterProto::RAW:
case IMAGETYPE_RAW:
return ImageWriter::createRawImageWriter(config);
case ImageWriterProto::D88:
case IMAGETYPE_D88:
return ImageWriter::createD88ImageWriter(config);
case ImageWriterProto::IMD:
case IMAGETYPE_IMD:
return ImageWriter::createImdImageWriter(config);
default:

View File

@@ -66,25 +66,14 @@ message ImdOutputProto
// NEXT_TAG: 12
message ImageWriterProto
{
enum ImageWriterType {
NOT_SET = 0;
IMG = 1;
D64 = 2;
LDBS = 3;
DISKCOPY = 4;
NSI = 5;
RAW = 6;
D88 = 7;
IMD = 8;
}
optional string filename = 1 [ (help) = "filename of output sector image" ];
optional bool filesystem_sector_order = 10 [
(help) = "read/write sector image in filesystem order",
default = false
];
optional ImageWriterType type = 11 [ default = NOT_SET, (help) = "image writer type" ];
optional ImageReaderWriterType type = 11
[ default = IMAGETYPE_NOT_SET, (help) = "image writer type" ];
optional ImgInputOutputProto img = 2;
optional D64OutputProto d64 = 3;

View File

@@ -2,6 +2,7 @@
#define PROTO_H
#include <google/protobuf/message.h>
#include "lib/common.pb.h"
#include "lib/config.pb.h"
class ProtoPathNotFoundException : public ErrorException

View File

@@ -236,7 +236,7 @@ std::unique_ptr<Filesystem> Filesystem::createFilesystemFromConfig()
fluxSource = globalConfig().getFluxSource();
decoder = globalConfig().getDecoder();
}
if (globalConfig()->flux_sink().type() == FluxSinkProto::DRIVE)
if (globalConfig()->flux_sink().type() == FLUXTYPE_DRIVE)
{
fluxSink = globalConfig().getFluxSink();
encoder = globalConfig().getEncoder();

View File

@@ -18,6 +18,8 @@ static std::string supportStatus(SupportStatus status)
case SupportStatus::UNSUPPORTED:
return "";
}
return "";
}
int main(int argc, const char* argv[])

View File

@@ -247,10 +247,10 @@ static void draw_x_graticules(Agg2D& painter,
int mainAnalyseDriveResponse(int argc, const char* argv[])
{
globalConfig().overrides()->mutable_flux_source()->set_type(
FluxSourceProto::DRIVE);
FLUXTYPE_DRIVE);
flags.parseFlagsWithConfigFiles(argc, argv, {});
if (globalConfig()->flux_sink().type() != FluxSinkProto::DRIVE)
if (globalConfig()->flux_sink().type() != FLUXTYPE_DRIVE)
error("this only makes sense with a real disk drive");
usbSetDrive(globalConfig()->drive().drive(),

View File

@@ -132,7 +132,7 @@ static nanoseconds_t guessClock(const Fluxmap& fluxmap)
int mainInspect(int argc, const char* argv[])
{
globalConfig().overrides()->mutable_flux_source()->set_type(
FluxSourceProto::DRIVE);
FLUXTYPE_DRIVE);
flags.parseFlagsWithConfigFiles(argc, argv, {});
auto& fluxSource = globalConfig().getFluxSource();

View File

@@ -57,10 +57,10 @@ int mainRawRead(int argc, const char* argv[])
if (argc == 1)
showProfiles("rawread", formats);
globalConfig().overrides()->mutable_flux_source()->set_type(
FluxSourceProto::DRIVE);
FLUXTYPE_DRIVE);
flags.parseFlagsWithConfigFiles(argc, argv, formats);
if (globalConfig()->flux_sink().type() == FluxSinkProto::DRIVE)
if (globalConfig()->flux_sink().type() == FLUXTYPE_DRIVE)
error("you can't use rawread to write to hardware");
std::shared_ptr<FluxSource> fluxSource = globalConfig().getFluxSource();

View File

@@ -49,7 +49,7 @@ static ActionFlag eraseFlag({"--erase"},
[]()
{
globalConfig().overrides()->mutable_flux_source()->set_type(
FluxSourceProto::ERASE);
FLUXTYPE_ERASE);
});
int mainRawWrite(int argc, const char* argv[])
@@ -60,10 +60,10 @@ int mainRawWrite(int argc, const char* argv[])
if (argc == 1)
showProfiles("rawwrite", formats);
globalConfig().overrides()->mutable_flux_sink()->set_type(
FluxSinkProto::DRIVE);
FLUXTYPE_DRIVE);
flags.parseFlagsWithConfigFiles(argc, argv, formats);
if (globalConfig()->flux_source().type() == FluxSourceProto::DRIVE)
if (globalConfig()->flux_source().type() == FLUXTYPE_DRIVE)
error("you can't use rawwrite to read from hardware");
auto& fluxSource = globalConfig().getFluxSource();

View File

@@ -61,10 +61,10 @@ int mainRead(int argc, const char* argv[])
{
if (argc == 1)
showProfiles("read", formats);
globalConfig().set("flux_source.type", "DRIVE");
globalConfig().set("flux_source.type", "FLUXTYPE_DRIVE");
flags.parseFlagsWithConfigFiles(argc, argv, formats);
if (globalConfig()->decoder().copy_flux_to().type() == FluxSinkProto::DRIVE)
if (globalConfig()->decoder().copy_flux_to().type() == FLUXTYPE_DRIVE)
error("you cannot copy flux to a hardware device");
auto& fluxSource = globalConfig().getFluxSource();

View File

@@ -19,7 +19,7 @@ int mainRpm(int argc, const char* argv[])
{
flags.parseFlagsWithConfigFiles(argc, argv, {});
if (globalConfig()->flux_source().type() != FluxSourceProto::DRIVE)
if (globalConfig()->flux_source().type() != FLUXTYPE_DRIVE)
error("this only makes sense with a real disk drive");
usbSetDrive(globalConfig()->drive().drive(),

View File

@@ -23,7 +23,7 @@ int mainSeek(int argc, const char* argv[])
{
flags.parseFlagsWithConfigFiles(argc, argv, {});
if (globalConfig()->flux_source().type() != FluxSourceProto::DRIVE)
if (globalConfig()->flux_source().type() != FLUXTYPE_DRIVE)
error("this only makes sense with a real disk drive");
usbSetDrive(globalConfig()->drive().drive(),

View File

@@ -22,7 +22,7 @@ they might require nudging as the side order can't be reliably autodetected.
image_writer {
filename: "acornadfs.img"
type: IMG
type: IMAGETYPE_IMG
}
decoder {

View File

@@ -25,12 +25,12 @@ documentation:
image_reader {
filename: "acorndfs.img"
type: IMG
type: IMAGETYPE_IMG
}
image_writer {
filename: "acorndfs.img"
type: IMG
type: IMAGETYPE_IMG
}
layout {

View File

@@ -43,7 +43,7 @@ documentation:
image_writer {
filename: "aeslanier.img"
type: IMG
type: IMAGETYPE_IMG
}
decoder {

View File

@@ -28,7 +28,7 @@ documentation:
image_writer {
filename: "agat.img"
type: IMG
type: IMAGETYPE_IMG
}
layout {

View File

@@ -31,12 +31,12 @@ documentation:
image_reader {
filename: "amiga.adf"
type: IMG
type: IMAGETYPE_IMG
}
image_writer {
filename: "amiga.adf"
type: IMG
type: IMAGETYPE_IMG
}
layout {

View File

@@ -44,7 +44,7 @@ documentation:
image_writer {
filename: "ampro.img"
type: IMG
type: IMAGETYPE_IMG
}
layout {

View File

@@ -19,12 +19,12 @@ on what was available at the time, with the same format on both.
image_reader {
filename: "bk800.img"
type: IMG
type: IMAGETYPE_IMG
}
image_writer {
filename: "bk800.img"
type: IMG
type: IMAGETYPE_IMG
}
layout {

View File

@@ -116,12 +116,12 @@ file system supports this.
image_reader {
filename: "brother.img"
type: IMG
type: IMAGETYPE_IMG
}
image_writer {
filename: "brother.img"
type: IMG
type: IMAGETYPE_IMG
}
encoder {

View File

@@ -54,12 +54,12 @@ documentation:
image_reader {
filename: "commodore.d64"
type: D64
type: IMAGETYPE_D64
}
image_writer {
filename: "commodore.d64"
type: D64
type: IMAGETYPE_D64
}
filesystem {

View File

@@ -37,7 +37,7 @@ documentation:
image_writer {
filename: "eco1.img"
type: IMG
type: IMAGETYPE_IMG
}
layout {

View File

@@ -11,7 +11,7 @@ format itself is yet another IBM scheme variant.
image_writer {
filename: "epsonpf10.img"
type: IMG
type: IMAGETYPE_IMG
}
layout {

View File

@@ -42,7 +42,7 @@ There's amazingly little information about these things.
image_writer {
filename: "f85.img"
type: IMG
type: IMAGETYPE_IMG
}
decoder {

View File

@@ -43,7 +43,7 @@ documentation:
image_writer {
filename: "fb100.img"
type: IMG
type: IMAGETYPE_IMG
}
decoder {

View File

@@ -20,12 +20,12 @@ drive {
image_reader {
filename: "hplif.img"
type: IMG
type: IMAGETYPE_IMG
}
image_writer {
filename: "hplif.img"
type: IMG
type: IMAGETYPE_IMG
}
decoder {

View File

@@ -84,12 +84,12 @@ versa, so it shouldn't matter.
image_reader {
filename: "ibm.img"
type: IMG
type: IMAGETYPE_IMG
}
image_writer {
filename: "ibm.img"
type: IMG
type: IMAGETYPE_IMG
}
decoder {

View File

@@ -11,7 +11,7 @@ track! Other than that it's another IBM scheme variation.
image_writer {
filename: "icl30.img"
type: IMG
type: IMAGETYPE_IMG
}
layout {

View File

@@ -61,12 +61,12 @@ documentation:
image_reader {
filename: "mac.dsk"
type: IMG
type: IMAGETYPE_IMG
}
image_writer {
filename: "mac.dsk"
type: IMG
type: IMAGETYPE_IMG
}
layout {

View File

@@ -67,12 +67,12 @@ drive {
image_reader {
filename: "micropolis.img"
type: IMG
type: IMAGETYPE_IMG
}
image_writer {
filename: "micropolis.img"
type: IMG
type: IMAGETYPE_IMG
}
layout {
@@ -100,12 +100,12 @@ option {
config {
image_reader {
filename: "micropolis.vgi"
type: IMG
type: IMAGETYPE_IMG
}
image_writer {
filename: "micropolis.vgi"
type: IMG
type: IMAGETYPE_IMG
}
layout {

View File

@@ -57,7 +57,7 @@ documentation:
image_writer {
filename: "mx.img"
type: IMG
type: IMAGETYPE_IMG
}
layout {

View File

@@ -19,12 +19,12 @@ drive {
image_reader {
filename: "n88basic.img"
type: IMG
type: IMAGETYPE_IMG
}
image_writer {
filename: "n88basic.img"
type: IMG
type: IMAGETYPE_IMG
}
layout {

View File

@@ -35,12 +35,12 @@ documentation:
image_reader {
filename: "northstar.nsi"
type: NSI
type: IMAGETYPE_NSI
}
image_writer {
filename: "northstar.nsi"
type: NSI
type: IMAGETYPE_NSI
}
layout {

View File

@@ -26,12 +26,12 @@ drive {
image_reader {
filename: "pme.img"
type: IMG
type: IMAGETYPE_IMG
}
image_writer {
filename: "pme.img"
type: IMG
type: IMAGETYPE_IMG
}
layout {

View File

@@ -20,7 +20,7 @@ you know anything about it.
image_writer {
filename: "rolandd20.img"
type: IMG
type: IMAGETYPE_IMG
}
layout {

View File

@@ -16,12 +16,12 @@ drive {
image_reader {
filename: "rx50.img"
type: IMG
type: IMAGETYPE_IMG
}
image_writer {
filename: "rx50.img"
type: IMG
type: IMAGETYPE_IMG
}
layout {

View File

@@ -29,7 +29,7 @@ documentation:
image_writer {
filename: "smaky6.img"
type: IMG
type: IMAGETYPE_IMG
}
layout {

View File

@@ -31,12 +31,12 @@ documentation:
image_reader {
filename: "tids990.img"
type: IMG
type: IMAGETYPE_IMG
}
image_writer {
filename: "tids990.img"
type: IMG
type: IMAGETYPE_IMG
}
layout {

View File

@@ -11,7 +11,7 @@ on the precise format.
image_writer {
filename: "tiki.img"
type: IMG
type: IMAGETYPE_IMG
}
decoder {

View File

@@ -50,12 +50,12 @@ documentation:
image_reader {
filename: "victor9k.img"
type: IMG
type: IMAGETYPE_IMG
}
image_writer {
filename: "victor9k.img"
type: IMG
type: IMAGETYPE_IMG
}
layout {

View File

@@ -40,7 +40,7 @@ documentation:
image_writer {
filename: "zilogmcz.img"
type: IMG
type: IMAGETYPE_IMG
}
decoder {

View File

@@ -46,6 +46,18 @@ static wxBitmap createBitmap(const uint8_t* data, size_t length)
return wxBitmap(image);
}
static void ignoreInapplicableValueExceptions(std::function<void(void)> cb)
{
try
{
cb();
}
catch (const InapplicableValueException* e)
{
/* swallow */
}
}
class IdlePanelImpl : public IdlePanelGen, public IdlePanel
{
enum
@@ -224,15 +236,31 @@ public:
case SELECTEDSOURCE_FLUX:
{
globalConfig().setFluxSink(_selectedFluxfilename);
globalConfig().setFluxSource(_selectedFluxfilename);
ignoreInapplicableValueExceptions(
[&]()
{
globalConfig().setFluxSink(_selectedFluxfilename);
});
ignoreInapplicableValueExceptions(
[&]()
{
globalConfig().setFluxSource(_selectedFluxfilename);
});
break;
}
case SELECTEDSOURCE_IMAGE:
{
ignoreInapplicableValueExceptions(
[&]()
{
globalConfig().setImageReader(_selectedImagefilename);
});
ignoreInapplicableValueExceptions(
[&]()
{
globalConfig().setImageWriter(_selectedImagefilename);
});
break;
}
}
@@ -587,12 +615,12 @@ private:
/* The current set of options is invalid for some reason. Just
* swallow the errors. */
}
catch (const ErrorException& e)
{
/* This really isn't supposed to happen, but sometimes does and
* it crashes the whole program. */
return;
}
catch (const ErrorException& e)
{
/* This really isn't supposed to happen, but sometimes does and
* it crashes the whole program. */
return;
}
assert(!wxGetApp().IsWorkerThreadRunning());

View File

@@ -53,11 +53,19 @@ private:
bool FluxEngineApp::OnInit()
{
try
{
wxImage::AddHandler(new wxPNGHandler());
Bind(EXEC_EVENT_TYPE, &FluxEngineApp::OnExec, this);
_mainWindow = CreateMainWindow();
_mainWindow->Show(true);
return true;
}
catch (const ErrorException* e)
{
fmt::print(stderr, "Exception on startup: {}\n", e->message);
exit(1);
}
}
wxThread::ExitCode FluxEngineApp::Entry()