Skip to content

Commit

Permalink
Merge pull request #155 from davidgiven/amigawriter
Browse files Browse the repository at this point in the history
Fix stray bytes at the end of images
  • Loading branch information
davidgiven authored Apr 7, 2020
2 parents 8dbd2a7 + 067af18 commit 5be7249
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/bytes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions lib/bytes.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class Bytes
ByteWriter writer();

void writeToFile(const std::string& filename) const;
void writeTo(std::ostream& stream) const;

private:
std::shared_ptr<std::vector<uint8_t>> _data;
Expand Down
2 changes: 1 addition & 1 deletion lib/imagewriter/imgimagewriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ImgImageWriter : public ImageWriter
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);
}
}
}
Expand Down

0 comments on commit 5be7249

Please sign in to comment.