Merge pull request #155 from davidgiven/amigawriter

Fix stray bytes at the end of images
This commit is contained in:
David Given
2020-04-07 23:13:23 +02:00
committed by GitHub
3 changed files with 7 additions and 1 deletions

View File

@@ -258,6 +258,11 @@ void Bytes::writeToFile(const std::string& filename) const
f.close();
}
void Bytes::writeTo(std::ostream& stream) const
{
stream.write((const char*) cbegin(), size());
}
ByteReader Bytes::reader() const
{
return ByteReader(*this);

View File

@@ -57,6 +57,7 @@ public:
ByteWriter writer();
void writeToFile(const std::string& filename) const;
void writeTo(std::ostream& stream) const;
private:
std::shared_ptr<std::vector<uint8_t>> _data;

View File

@@ -46,7 +46,7 @@ public:
if (sector)
{
outputFile.seekp(sector->logicalTrack*trackSize + sector->logicalSide*headSize + sector->logicalSector*numBytes, std::ios::beg);
outputFile.write((const char*) sector->data.cbegin(), sector->data.size());
sector->data.slice(0, numBytes).writeTo(outputFile);
}
}
}