Make the new FL2 flux format the default.

This commit is contained in:
dg
2021-12-05 17:09:02 +00:00
parent 930e0bcd67
commit 27fceb3f41
7 changed files with 19 additions and 11 deletions

View File

@@ -21,7 +21,7 @@ jobs:
with:
fetch-depth: 1
- name: brew
run: brew install sqlite pkg-config libusb ninja protobuf
run: brew install sqlite pkg-config libusb ninja protobuf truncate
- name: make
run: make

View File

@@ -1,5 +1,9 @@
syntax = "proto2";
enum FluxMagic {
MAGIC = 0x466c7578;
}
enum FluxFileVersion {
VERSION_1 = 1;
}
@@ -11,7 +15,8 @@ message TrackFluxProto {
}
message FluxFileProto {
optional FluxFileVersion version = 1;
repeated TrackFluxProto track = 2;
optional int32 magic = 1;
optional FluxFileVersion version = 2;
repeated TrackFluxProto track = 3;
}

View File

@@ -28,6 +28,7 @@ public:
~Fl2FluxSink()
{
FluxFileProto proto;
proto.set_magic(FluxMagic::MAGIC);
proto.set_version(FluxFileVersion::VERSION_1);
for (const auto& e : _data)
{

View File

@@ -39,9 +39,8 @@ void FluxSink::updateConfigForFilename(FluxSinkProto* proto, const std::string&
{
static const std::vector<std::pair<std::regex, std::function<void(const std::string&)>>> formats =
{
{ std::regex("^(.*\\.flux)$"), [&](const auto& s) { proto->set_fluxfile(s); }},
{ std::regex("^(.*\\.flux)$"), [&](const auto& s) { proto->mutable_fl2()->set_filename(s); }},
{ std::regex("^(.*\\.scp)$"), [&](const auto& s) { proto->mutable_scp()->set_filename(s); }},
{ std::regex("^(.*\\.fl2)$"), [&](const auto& s) { proto->mutable_fl2()->set_filename(s); }},
{ std::regex("^vcd:(.*)$"), [&](const auto& s) { proto->mutable_vcd()->set_directory(s); }},
{ std::regex("^au:(.*)$"), [&](const auto& s) { proto->mutable_au()->set_directory(s); }},
{ std::regex("^drive:(.*)"), [&](const auto& s) { proto->mutable_drive()->set_drive(std::stoi(s)); }},

View File

@@ -50,6 +50,13 @@ private:
std::unique_ptr<FluxSource> FluxSource::createFl2FluxSource(const Fl2FluxSourceProto& config)
{
char buffer[16];
std::ifstream(config.filename(), std::ios::in | std::ios::binary).read(buffer, 16);
if (strncmp(buffer, "SQLite format 3", 16) == 0)
{
std::cerr << "Warning: reading a deprecated flux file format; please upgrade it\n";
return FluxSource::createSqliteFluxSource(config.filename());
}
return std::unique_ptr<FluxSource>(new Fl2FluxSource(config));
}

View File

@@ -50,12 +50,12 @@ std::unique_ptr<FluxSource> FluxSource::create(const FluxSourceProto& config)
void FluxSource::updateConfigForFilename(FluxSourceProto* proto, const std::string& filename)
{
static const std::vector<std::pair<std::regex, std::function<void(const std::string&)>>> formats =
{
{ std::regex("^(.*\\.flux)$"), [&](const auto& s) { proto->set_fluxfile(s); }},
{ std::regex("^(.*\\.flux)$"), [&](const auto& s) { proto->mutable_fl2()->set_filename(s); }},
{ std::regex("^(.*\\.scp)$"), [&](const auto& s) { proto->mutable_scp()->set_filename(s); }},
{ std::regex("^(.*\\.cwf)$"), [&](const auto& s) { proto->mutable_cwf()->set_filename(s); }},
{ std::regex("^(.*\\.fl2)$"), [&](const auto& s) { proto->mutable_fl2()->set_filename(s); }},
{ std::regex("^erase:$"), [&](const auto& s) { proto->mutable_erase(); }},
{ std::regex("^kryoflux:(.*)$"), [&](const auto& s) { proto->mutable_kryoflux()->set_directory(s); }},
{ std::regex("^testpattern:(.*)"), [&](const auto& s) { proto->mutable_test_pattern(); }},

View File

@@ -270,10 +270,6 @@ encodedecodetest() {
echo " format=$format"
echo " configs=$*"
echo " fluxx=scp"
echo "build $OBJDIR/$format.encodedecode.fl2.stamp : encodedecode | fluxengine$EXTENSION scripts/encodedecodetest.sh $*"
echo " format=$format"
echo " configs=$*"
echo " fluxx=fl2"
}
buildlibrary libagg.a \