fixed up qdatastream usage. use writeRawData() when creating hdd images. specify littleendian when creating floppy images

This commit is contained in:
Joakim L. Gilje
2021-12-06 10:50:58 +01:00
parent 37e29de342
commit 28d1a43af7
2 changed files with 6 additions and 2 deletions

View File

@@ -371,12 +371,12 @@ void HarddiskDialog::onCreateNewFile() {
uint64_t restBlock = size & 0xfffff; uint64_t restBlock = size & 0xfffff;
if (restBlock) { if (restBlock) {
stream << QByteArray::fromRawData(buf.data(), restBlock); stream.writeRawData(buf.data(), restBlock);
} }
if (mibBlocks) { if (mibBlocks) {
for (uint64_t i = 0; i < mibBlocks; ++i) { for (uint64_t i = 0; i < mibBlocks; ++i) {
stream << buf; stream.writeRawData(buf.data(), buf.size());
emit fileProgress(static_cast<int>((i * 100) / mibBlocks)); emit fileProgress(static_cast<int>((i * 100) / mibBlocks));
} }
} }

View File

@@ -271,6 +271,7 @@ bool NewFloppyDialog::create86f(const QString& filename, const disk_size_t& disk
return false; return false;
} }
QDataStream stream(&file); QDataStream stream(&file);
stream.setByteOrder(QDataStream::LittleEndian);
stream << magic; stream << magic;
stream << version; stream << version;
@@ -314,6 +315,7 @@ bool NewFloppyDialog::createSectorImage(const QString &filename, const disk_size
return false; return false;
} }
QDataStream stream(&file); QDataStream stream(&file);
stream.setByteOrder(QDataStream::LittleEndian);
sector_bytes = (128 << disk_size.sector_len); sector_bytes = (128 << disk_size.sector_len);
total_sectors = disk_size.sides * disk_size.tracks * disk_size.sectors; total_sectors = disk_size.sides * disk_size.tracks * disk_size.sectors;
@@ -411,6 +413,7 @@ bool NewFloppyDialog::createZipSectorImage(const QString &filename, const disk_s
return false; return false;
} }
QDataStream stream(&file); QDataStream stream(&file);
stream.setByteOrder(QDataStream::LittleEndian);
sector_bytes = (128 << disk_size.sector_len); sector_bytes = (128 << disk_size.sector_len);
total_sectors = disk_size.sides * disk_size.tracks * disk_size.sectors; total_sectors = disk_size.sides * disk_size.tracks * disk_size.sectors;
@@ -599,6 +602,7 @@ bool NewFloppyDialog::createMoSectorImage(const QString& filename, int8_t disk_s
return false; return false;
} }
QDataStream stream(&file); QDataStream stream(&file);
stream.setByteOrder(QDataStream::LittleEndian);
sector_bytes = dp->bytes_per_sector; sector_bytes = dp->bytes_per_sector;
total_sectors = dp->sectors; total_sectors = dp->sectors;