Skip to content

Commit 1c02f36

Browse files
committed
FileSystem cleanup
1 parent 4c0de5f commit 1c02f36

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

Core/FileSystems/FSBlock.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
namespace vamiga {
1717

18-
FSBlock::FSBlock(FileSystem &ref, Block nr, FSBlockType t) : device(ref)
18+
FSBlock::FSBlock(FileSystem &ref, Block nr, FSBlockType t) : fs(ref)
1919
{
2020
this->nr = nr;
2121
init(t);
@@ -36,11 +36,11 @@ FSBlock::init(FSBlockType t)
3636

3737
case FSBlockType::BOOT_BLOCK:
3838

39-
if (nr == 0 && device.dos != FSVolumeType::NODOS) {
39+
if (nr == 0 && fs.dos != FSVolumeType::NODOS) {
4040
data[0] = 'D';
4141
data[1] = 'O';
4242
data[2] = 'S';
43-
data[3] = (u8)device.dos;
43+
data[3] = (u8)fs.dos;
4444
}
4545
break;
4646

@@ -137,7 +137,7 @@ FSBlock::objectName() const
137137
isize
138138
FSBlock::bsize() const
139139
{
140-
return device.bsize;
140+
return fs.bsize;
141141
}
142142

143143
isize
@@ -641,7 +641,7 @@ FSBlock::checksumBootBlock() const
641641
}
642642

643643
// Second boot block
644-
u8 *p = device.blocks[1]->data.ptr;
644+
u8 *p = fs.blocks[1]->data.ptr;
645645

646646
for (isize i = 0; i < bsize() / 4; i++) {
647647

@@ -809,7 +809,7 @@ Fault
809809
FSBlock::exportUserDirBlock(const fs::path &path)
810810
{
811811
// Assemble the host file name
812-
auto filename = path / FSPath(device, nr).getPath();
812+
auto filename = path / FSPath(fs, nr).getPath();
813813
debug(FS_DEBUG >= 2, "Creating directory %s\n", filename.string().c_str());
814814

815815
// Create directory
@@ -822,7 +822,7 @@ Fault
822822
FSBlock::exportFileHeaderBlock(const fs::path &path)
823823
{
824824
// Assemble the host file name
825-
auto filename = path / FSPath(device, nr).getPath(); // device.getPath(this);
825+
auto filename = path / FSPath(fs, nr).getPath(); // device.getPath(this);
826826
debug(FS_DEBUG >= 2, " Exporting file %s\n", filename.string().c_str());
827827

828828
// Open file
@@ -1079,7 +1079,7 @@ FSBlock *
10791079
FSBlock::getParentDirBlock() const
10801080
{
10811081
Block nr = getParentDirRef();
1082-
return nr ? device.blockPtr(nr) : nullptr;
1082+
return nr ? fs.blockPtr(nr) : nullptr;
10831083
}
10841084

10851085
Block
@@ -1112,7 +1112,7 @@ FSBlock *
11121112
FSBlock::getFileHeaderBlock() const
11131113
{
11141114
Block nr = getFileHeaderRef();
1115-
return nr ? device.fileHeaderBlockPtr(nr) : nullptr;
1115+
return nr ? fs.fileHeaderBlockPtr(nr) : nullptr;
11161116
}
11171117

11181118
Block
@@ -1150,7 +1150,7 @@ FSBlock *
11501150
FSBlock::getNextHashBlock() const
11511151
{
11521152
Block nr = getNextHashRef();
1153-
return nr ? device.blockPtr(nr) : nullptr;
1153+
return nr ? fs.blockPtr(nr) : nullptr;
11541154
}
11551155

11561156
Block
@@ -1188,7 +1188,7 @@ FSBlock *
11881188
FSBlock::getNextListBlock() const
11891189
{
11901190
Block nr = getNextListBlockRef();
1191-
return nr ? device.fileListBlockPtr(nr) : nullptr;
1191+
return nr ? fs.fileListBlockPtr(nr) : nullptr;
11921192
}
11931193

11941194
Block
@@ -1221,7 +1221,7 @@ FSBlock *
12211221
FSBlock::getNextBmExtBlock() const
12221222
{
12231223
Block nr = getNextBmExtBlockRef();
1224-
return nr ? device.bitmapExtBlockPtr(nr) : nullptr;
1224+
return nr ? fs.bitmapExtBlockPtr(nr) : nullptr;
12251225
}
12261226

12271227
Block
@@ -1258,7 +1258,7 @@ FSBlock *
12581258
FSBlock::getFirstDataBlock() const
12591259
{
12601260
Block nr = getFirstDataBlockRef();
1261-
return nr ? device.dataBlockPtr(nr) : nullptr;
1261+
return nr ? fs.dataBlockPtr(nr) : nullptr;
12621262
}
12631263

12641264
Block
@@ -1308,7 +1308,7 @@ FSBlock *
13081308
FSBlock::getNextDataBlock() const
13091309
{
13101310
Block nr = getNextDataBlockRef();
1311-
return nr ? device.dataBlockPtr(nr) : nullptr;
1311+
return nr ? fs.dataBlockPtr(nr) : nullptr;
13121312
}
13131313

13141314
isize
@@ -1643,7 +1643,7 @@ FSBlock::writeData(Buffer<u8> &buf)
16431643
// Start here and iterate through all connected file list blocks
16441644
FSBlock *block = this;
16451645

1646-
while (block && blocksTotal < device.numBlocks()) {
1646+
while (block && blocksTotal < fs.numBlocks()) {
16471647

16481648
blocksTotal++;
16491649

@@ -1652,7 +1652,7 @@ FSBlock::writeData(Buffer<u8> &buf)
16521652
for (isize i = 0; i < num; i++) {
16531653

16541654
Block ref = block->getDataBlockRef(i);
1655-
if (FSBlock *dataBlock = device.dataBlockPtr(ref)) {
1655+
if (FSBlock *dataBlock = fs.dataBlockPtr(ref)) {
16561656

16571657
isize bytesWritten = dataBlock->writeData(buf, bytesTotal, bytesRemaining);
16581658
bytesTotal += bytesWritten;
@@ -1712,7 +1712,7 @@ FSBlock::overwriteData(Buffer<u8> &buf)
17121712
// Start here and iterate through all connected file list blocks
17131713
FSBlock *block = this;
17141714

1715-
while (block && blocksTotal < device.numBlocks()) {
1715+
while (block && blocksTotal < fs.numBlocks()) {
17161716

17171717
blocksTotal++;
17181718

@@ -1721,7 +1721,7 @@ FSBlock::overwriteData(Buffer<u8> &buf)
17211721
for (isize i = 0; i < num; i++) {
17221722

17231723
Block ref = block->getDataBlockRef(i);
1724-
if (FSBlock *dataBlock = device.dataBlockPtr(ref)) {
1724+
if (FSBlock *dataBlock = fs.dataBlockPtr(ref)) {
17251725

17261726
isize bytesWritten = dataBlock->overwriteData(buf, bytesTotal, bytesRemaining);
17271727
bytesTotal += bytesWritten;

Core/FileSystems/FSBlock.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ using util::Buffer;
2323

2424
struct FSBlock : CoreObject {
2525

26-
// The device this block belongs to
27-
class FileSystem &device;
26+
// The file system this block belongs to
27+
class FileSystem &fs;
2828

2929
// The type of this block
3030
FSBlockType type = FSBlockType::UNKNOWN_BLOCK;
@@ -347,43 +347,43 @@ if (value > (u32)exp) \
347347
if (!FSVolumeTypeEnum::isValid((isize)value)) return Fault::FS_EXPECTED_DOS_REVISION; }
348348

349349
#define EXPECT_REF { \
350-
if (!device.block(value)) return Fault::FS_EXPECTED_REF; }
350+
if (!fs.block(value)) return Fault::FS_EXPECTED_REF; }
351351

352352
#define EXPECT_SELFREF { \
353353
if (value != nr) return Fault::FS_EXPECTED_SELFREF; }
354354

355355
#define EXPECT_FILEHEADER_REF { \
356-
if (Fault e = device.checkBlockType(value, FSBlockType::FILEHEADER_BLOCK); e != Fault::OK) return e; }
356+
if (Fault e = fs.checkBlockType(value, FSBlockType::FILEHEADER_BLOCK); e != Fault::OK) return e; }
357357

358358
#define EXPECT_HASH_REF { \
359-
if (Fault e = device.checkBlockType(value, FSBlockType::FILEHEADER_BLOCK, FSBlockType::USERDIR_BLOCK); e != Fault::OK) return e; }
359+
if (Fault e = fs.checkBlockType(value, FSBlockType::FILEHEADER_BLOCK, FSBlockType::USERDIR_BLOCK); e != Fault::OK) return e; }
360360

361361
#define EXPECT_OPTIONAL_HASH_REF { \
362362
if (value) { EXPECT_HASH_REF } }
363363

364364
#define EXPECT_PARENT_DIR_REF { \
365-
if (Fault e = device.checkBlockType(value, FSBlockType::ROOT_BLOCK, FSBlockType::USERDIR_BLOCK); e != Fault::OK) return e; }
365+
if (Fault e = fs.checkBlockType(value, FSBlockType::ROOT_BLOCK, FSBlockType::USERDIR_BLOCK); e != Fault::OK) return e; }
366366

367367
#define EXPECT_FILELIST_REF { \
368-
if (Fault e = device.checkBlockType(value, FSBlockType::FILELIST_BLOCK); e != Fault::OK) return e; }
368+
if (Fault e = fs.checkBlockType(value, FSBlockType::FILELIST_BLOCK); e != Fault::OK) return e; }
369369

370370
#define EXPECT_OPTIONAL_FILELIST_REF { \
371371
if (value) { EXPECT_FILELIST_REF } }
372372

373373
#define EXPECT_BITMAP_REF { \
374-
if (Fault e = device.checkBlockType(value, FSBlockType::BITMAP_BLOCK); e != Fault::OK) return e; }
374+
if (Fault e = fs.checkBlockType(value, FSBlockType::BITMAP_BLOCK); e != Fault::OK) return e; }
375375

376376
#define EXPECT_OPTIONAL_BITMAP_REF { \
377377
if (value) { EXPECT_BITMAP_REF } }
378378

379379
#define EXPECT_BITMAP_EXT_REF { \
380-
if (Fault e = device.checkBlockType(value, FSBlockType::BITMAP_EXT_BLOCK); e != Fault::OK) return e; }
380+
if (Fault e = fs.checkBlockType(value, FSBlockType::BITMAP_EXT_BLOCK); e != Fault::OK) return e; }
381381

382382
#define EXPECT_OPTIONAL_BITMAP_EXT_REF { \
383383
if (value) { EXPECT_BITMAP_EXT_REF } }
384384

385385
#define EXPECT_DATABLOCK_REF { \
386-
if (Fault e = device.checkBlockType(value, FSBlockType::DATA_BLOCK_OFS, FSBlockType::DATA_BLOCK_FFS); e != Fault::OK) return e; }
386+
if (Fault e = fs.checkBlockType(value, FSBlockType::DATA_BLOCK_OFS, FSBlockType::DATA_BLOCK_FFS); e != Fault::OK) return e; }
387387

388388
#define EXPECT_OPTIONAL_DATABLOCK_REF { \
389389
if (value) { EXPECT_DATABLOCK_REF } }

0 commit comments

Comments
 (0)