Skip to content

Commit 3dc1659

Browse files
committed
Added more const keywords
1 parent 96b2e16 commit 3dc1659

File tree

11 files changed

+41
-32
lines changed

11 files changed

+41
-32
lines changed

Core/FileSystems/FileSystem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ FileSystem::init(const HDFFile &hdf, isize part)
5959
}
6060

6161
void
62-
FileSystem::init(FloppyDrive &dfn)
62+
FileSystem::init(const FloppyDrive &dfn)
6363
{
6464
// Convert the floppy drive into an ADF
6565
auto adf = ADFFile(dfn);
@@ -79,7 +79,7 @@ FileSystem::init(const HardDrive &hdn, isize part)
7979
}
8080

8181
void
82-
FileSystem::init(FileSystemDescriptor layout, u8 *buf, isize len)
82+
FileSystem::init(const FileSystemDescriptor &layout, u8 *buf, isize len)
8383
{
8484
assert(buf);
8585

Core/FileSystems/FileSystem.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,16 @@ class FileSystem : public CoreObject, public Inspectable<FSInfo, FSStats> {
8080
FileSystem(const MediaFile &file, isize part = 0) : FileSystem() { init(file, part); }
8181
FileSystem(const ADFFile &adf) : FileSystem() { init(adf); }
8282
FileSystem(const HDFFile &hdf, isize part = 0) : FileSystem() { init(hdf, part); }
83-
FileSystem(FloppyDrive &dfn) : FileSystem() { init(dfn); }
83+
FileSystem(const FloppyDrive &dfn) : FileSystem() { init(dfn); }
8484
FileSystem(const HardDrive &hdn, isize part = 0) : FileSystem() { init(hdn, part); }
8585

8686
virtual ~FileSystem();
8787

88-
void init(FileSystemDescriptor layout, u8 *buf, isize len);
88+
void init(const FileSystemDescriptor &layout, u8 *buf, isize len);
8989
void init(const MediaFile &file, isize part);
9090
void init(const ADFFile &adf);
9191
void init(const HDFFile &hdf, isize part);
92-
void init(FloppyDrive &dfn);
92+
void init(const FloppyDrive &dfn);
9393
void init(const HardDrive &hdn, isize part);
9494

9595
bool isInitialized() const noexcept;

Core/Media/DiskFiles/ADFFile.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ ADFFile::init(const FloppyDiskDescriptor &descr)
107107
}
108108

109109
void
110-
ADFFile::init(FloppyDisk &disk)
110+
ADFFile::init(const FloppyDisk &disk)
111111
{
112112
init(disk.getDiameter(), disk.getDensity());
113113

@@ -118,14 +118,14 @@ ADFFile::init(FloppyDisk &disk)
118118
}
119119

120120
void
121-
ADFFile::init(FloppyDrive &drive)
121+
ADFFile::init(const FloppyDrive &drive)
122122
{
123123
if (drive.disk == nullptr) throw AppError(Fault::DISK_MISSING);
124124
init(*drive.disk);
125125
}
126126

127127
void
128-
ADFFile::init(MutableFileSystem &volume)
128+
ADFFile::init(const MutableFileSystem &volume)
129129
{
130130
switch (volume.numBlocks()) {
131131

@@ -438,24 +438,27 @@ ADFFile::dumpSector(Sector s) const
438438
}
439439

440440
void
441-
ADFFile::decodeDisk(FloppyDisk &disk)
441+
ADFFile::decodeDisk(const FloppyDisk &disk)
442442
{
443443
long tracks = numTracks();
444-
444+
445445
debug(ADF_DEBUG, "Decoding Amiga disk with %ld tracks\n", tracks);
446-
446+
447447
if (disk.getDiameter() != getDiameter()) {
448448
throw AppError(Fault::DISK_INVALID_DIAMETER);
449449
}
450450
if (disk.getDensity() != getDensity()) {
451451
throw AppError(Fault::DISK_INVALID_DENSITY);
452452
}
453453

454+
// Make a copy of the disk which can modify
455+
auto diskCopy = disk;
456+
454457
// Make the MFM stream scannable beyond the track end
455-
disk.repeatTracks();
458+
diskCopy.repeatTracks();
456459

457460
// Decode all tracks
458-
for (Track t = 0; t < tracks; t++) decodeTrack(disk, t);
461+
for (Track t = 0; t < tracks; t++) decodeTrack(diskCopy, t);
459462
}
460463

461464
void

Core/Media/DiskFiles/ADFFile.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ class ADFFile : public FloppyFile {
4949
ADFFile(const u8 *buf, isize len) throws { init(buf, len); }
5050
ADFFile(Diameter dia, Density den) throws { init(dia, den); }
5151
ADFFile(const FloppyDiskDescriptor &descr) throws { init(descr); }
52-
ADFFile(class FloppyDisk &disk) throws { init(disk); }
53-
ADFFile(class FloppyDrive &drive) throws { init(drive); }
54-
ADFFile(MutableFileSystem &volume) throws { init(volume); }
52+
ADFFile(const class FloppyDisk &disk) throws { init(disk); }
53+
ADFFile(const class FloppyDrive &drive) throws { init(drive); }
54+
ADFFile(const MutableFileSystem &volume) throws { init(volume); }
5555

5656
void init(Diameter dia, Density den) throws;
5757
void init(const FloppyDiskDescriptor &descr) throws;
58-
void init(FloppyDisk &disk) throws;
59-
void init(FloppyDrive &drive) throws;
60-
void init(MutableFileSystem &volume) throws;
58+
void init(const FloppyDisk &disk) throws;
59+
void init(const FloppyDrive &drive) throws;
60+
void init(const MutableFileSystem &volume) throws;
6161

6262

6363
//
@@ -104,7 +104,7 @@ class ADFFile : public FloppyFile {
104104
void killVirus() override;
105105

106106
void encodeDisk(class FloppyDisk &disk) const throws override;
107-
void decodeDisk(class FloppyDisk &disk) throws override;
107+
void decodeDisk(const class FloppyDisk &disk) throws override;
108108

109109
private:
110110

Core/Media/DiskFiles/EADFFile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ EADFFile::encodeExtendedTrack(class FloppyDisk &disk, Track t) const
239239
}
240240

241241
void
242-
EADFFile::decodeDisk(FloppyDisk &disk)
242+
EADFFile::decodeDisk(const FloppyDisk &disk)
243243
{
244244
assert(!data.empty());
245245

Core/Media/DiskFiles/EADFFile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class EADFFile : public FloppyFile {
115115
void readSector(u8 *dst, isize t, isize s) const override { }
116116

117117
void encodeDisk(class FloppyDisk &disk) const throws override;
118-
void decodeDisk(class FloppyDisk &disk) throws override;
118+
void decodeDisk(const class FloppyDisk &disk) throws override;
119119

120120
private:
121121

Core/Media/DiskFiles/FloppyFile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class FloppyFile : public DiskFile {
7373
public:
7474

7575
virtual void encodeDisk(FloppyDisk &disk) const throws { fatalError; }
76-
virtual void decodeDisk(FloppyDisk &disk) throws { fatalError; }
76+
virtual void decodeDisk(const FloppyDisk &disk) throws { fatalError; }
7777
};
7878

7979
}

Core/Media/DiskFiles/IMGFile.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ IMGFile::encodeSector(FloppyDisk &disk, Track t, Sector s) const
204204
}
205205

206206
void
207-
IMGFile::decodeDisk(FloppyDisk &disk)
207+
IMGFile::decodeDisk(const FloppyDisk &disk)
208208
{
209209
long tracks = numTracks();
210210

@@ -216,12 +216,15 @@ IMGFile::decodeDisk(FloppyDisk &disk)
216216
if (disk.getDensity() != getDensity()) {
217217
throw AppError(Fault::DISK_INVALID_DENSITY);
218218
}
219-
219+
220+
// Make a copy of the disk which can modify
221+
auto diskCopy = disk;
222+
220223
// Make the MFM stream scannable beyond the track end
221-
disk.repeatTracks();
224+
diskCopy.repeatTracks();
222225

223226
// Decode all tracks
224-
for (Track t = 0; t < tracks; t++) decodeTrack(disk, t);
227+
for (Track t = 0; t < tracks; t++) decodeTrack(diskCopy, t);
225228
}
226229

227230
void

Core/Media/DiskFiles/IMGFile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class IMGFile : public FloppyFile {
8282
Diameter getDiameter() const override { return Diameter::INCH_35; }
8383
Density getDensity() const override { return Density::DD; }
8484
void encodeDisk(class FloppyDisk &disk) const throws override;
85-
void decodeDisk(class FloppyDisk &disk) throws override;
85+
void decodeDisk(const class FloppyDisk &disk) throws override;
8686

8787
private:
8888

Core/Media/DiskFiles/STFile.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ STFile::encodeSector(FloppyDisk &disk, Track t, Sector s) const
200200
}
201201

202202
void
203-
STFile::decodeDisk(FloppyDisk &disk)
203+
STFile::decodeDisk(const FloppyDisk &disk)
204204
{
205205
long tracks = numTracks();
206206

@@ -213,11 +213,14 @@ STFile::decodeDisk(FloppyDisk &disk)
213213
throw AppError(Fault::DISK_INVALID_DENSITY);
214214
}
215215

216+
// Make a copy of the disk which can modify
217+
auto diskCopy = disk;
218+
216219
// Make the MFM stream scannable beyond the track end
217-
disk.repeatTracks();
220+
diskCopy.repeatTracks();
218221

219222
// Decode all tracks
220-
for (Track t = 0; t < tracks; t++) decodeTrack(disk, t);
223+
for (Track t = 0; t < tracks; t++) decodeTrack(diskCopy, t);
221224
}
222225

223226
void

0 commit comments

Comments
 (0)