mirror of
https://github.com/davidgiven/fluxengine.git
synced 2025-10-31 11:17:01 -07:00
Archive.
This commit is contained in:
@@ -6,12 +6,13 @@ enum FluxMagic {
|
||||
|
||||
enum FluxFileVersion {
|
||||
VERSION_1 = 1;
|
||||
VERSION_2 = 2;
|
||||
}
|
||||
|
||||
message TrackFluxProto {
|
||||
optional int32 cylinder = 1;
|
||||
optional int32 head = 2;
|
||||
optional bytes flux = 3;
|
||||
repeated bytes flux = 3;
|
||||
}
|
||||
|
||||
message FluxFileProto {
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
{
|
||||
FluxFileProto proto;
|
||||
proto.set_magic(FluxMagic::MAGIC);
|
||||
proto.set_version(FluxFileVersion::VERSION_1);
|
||||
proto.set_version(FluxFileVersion::VERSION_2);
|
||||
for (const auto& e : _data)
|
||||
{
|
||||
auto track = proto.add_track();
|
||||
|
||||
@@ -20,6 +20,7 @@ public:
|
||||
|
||||
if (!_proto.ParseFromIstream(&ifs))
|
||||
Error() << "unable to read input file";
|
||||
upgradeFluxFile();
|
||||
}
|
||||
|
||||
public:
|
||||
@@ -43,6 +44,29 @@ private:
|
||||
Error() << fmt::format("FL2 read I/O error: {}", strerror(errno));
|
||||
}
|
||||
|
||||
void upgradeFluxFile()
|
||||
{
|
||||
if (_proto.version() == FluxFileVersion::VERSION_1)
|
||||
{
|
||||
/* Change a flux datastream with multiple segments separated by F_DESYNC into multiple
|
||||
* flux segments. */
|
||||
|
||||
for (auto* track = _proto.mutable_track())
|
||||
{
|
||||
Fluxmap old_flux(track.flux(0));
|
||||
auto split_flux = old_flux.split();
|
||||
|
||||
track.clear_flux();
|
||||
for (const auto& flux : split_flux)
|
||||
track.add_flux(flux.rawBytes());
|
||||
}
|
||||
|
||||
_proto.set_version(FluxFileVersion::VERSION_2);
|
||||
}
|
||||
if (_proto.version() > FluxFileVersion::VERSION_2)
|
||||
Error() << fmt::format("this is a version {} flux file, but this build of the client can only handle up to version {} --- please upgrade", _proto.version(), FluxFileVersion::VERSION_2);
|
||||
}
|
||||
|
||||
private:
|
||||
const Fl2FluxSourceProto& _config;
|
||||
FluxFileProto _proto;
|
||||
|
||||
Reference in New Issue
Block a user