MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / writeImage

Method writeImage

lib/imagewriter/d64imagewriter.cc:29–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27 D64ImageWriter(const ImageWriterProto& config): ImageWriter(config) {}
28
29 void writeImage(const Image& image) override
30 {
31 log("D64: writing triangular image");
32
33 std::ofstream outputFile(
34 _config.filename(), std::ios::out | std::ios::binary);
35 if (!outputFile.is_open())
36 error("cannot open output file");
37
38 uint32_t offset = 0;
39 for (int track = 0; track < 40; track++)
40 {
41 int sectorCount = sectors_per_track(track);
42 for (int sectorId = 0; sectorId < sectorCount; sectorId++)
43 {
44 const auto& sector = image.get(track, 0, sectorId);
45 if (sector)
46 {
47 outputFile.seekp(offset);
48 outputFile.write((const char*)sector->data.cbegin(),
49 sector->data.size());
50 }
51
52 offset += 256;
53 }
54 }
55 }
56};
57
58std::unique_ptr<ImageWriter> ImageWriter::createD64ImageWriter(

Callers

nothing calls this directly

Calls 7

errorFunction · 0.85
sectors_per_trackFunction · 0.85
cbeginMethod · 0.80
logFunction · 0.50
getMethod · 0.45
writeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected