Convert all the encoders and imagereaders to the new scheme.

This commit is contained in:
David Given
2021-07-15 23:43:07 +02:00
parent fa36af454e
commit 239cecff9e
18 changed files with 108 additions and 71 deletions

View File

@@ -3,6 +3,7 @@
#include "sector.h"
#include "sectorset.h"
#include "imagereader/imagereader.h"
#include "image.h"
#include "fmt/format.h"
#include "lib/config.pb.h"
#include <algorithm>
@@ -81,7 +82,7 @@ public:
ImageReader(config)
{}
SectorSet readImage()
Image readImage()
{
std::ifstream inputFile(_config.filename(), std::ios::in | std::ios::binary);
if (!inputFile.is_open())
@@ -90,7 +91,7 @@ public:
inputFile.seekg( 0, std::ios::end);
unsigned inputFileSize = inputFile.tellg();
unsigned headerPtr = 0;
SectorSet sectors;
Image image;
for (;;)
{
unsigned dataPtr = headerPtr + 2901*3 + 1;
@@ -110,8 +111,7 @@ public:
inputFile.read((char*) data.begin(), sectorSize);
unsigned head = !!(header.flags & JV3_SIDE);
std::unique_ptr<Sector>& sector = sectors.get(header.track, head, header.sector);
sector.reset(new Sector);
Sector* sector = image.put(header.track, head, header.sector);
sector->status = Sector::OK;
sector->logicalTrack = sector->physicalCylinder = header.track;
sector->logicalSide = sector->physicalHead = head;
@@ -128,7 +128,8 @@ public:
headerPtr = dataPtr;
}
return sectors;
image.calculateSize();
return image;
}
};