31 [[nodiscard]]
bool hasChanged()
const override;
37 DirIndex(
unsigned sector_,
unsigned idx_)
38 : sector(sector_), idx(idx_) {}
39 [[nodiscard]]
constexpr bool operator==(
const DirIndex&)
const =
default;
45 auto operator()(
const DirIndex& d)
const {
46 std::hash<unsigned> subHasher;
47 return 31 * subHasher(d.sector)
62 [[nodiscard]] std::span<SectorBuffer> fat();
63 [[nodiscard]] std::span<SectorBuffer> fat2();
64 [[nodiscard]] MSXDirEntry& msxDir(DirIndex dirIndex);
65 void writeFATSector (
unsigned sector,
const SectorBuffer& buf);
66 void writeDIRSector (
unsigned sector, DirIndex dirDirIndex,
67 const SectorBuffer& buf);
68 void writeDataSector(
unsigned sector,
const SectorBuffer& buf);
69 void writeDIREntry(DirIndex dirIndex, DirIndex dirDirIndex,
70 const MSXDirEntry& newEntry);
72 void checkDeletedHostFiles();
73 void deleteMSXFile(DirIndex dirIndex);
74 void deleteMSXFilesInDir(
unsigned msxDirSector);
75 void freeFATChain(
unsigned cluster);
76 void addNewHostFiles(
const std::string& hostSubDir,
unsigned msxDirSector);
77 void addNewDirectory(
const std::string& hostSubDir,
const std::string& hostName,
79 void addNewHostFile(
const std::string& hostSubDir,
const std::string& hostName,
81 [[nodiscard]] DirIndex fillMSXDirEntry(
82 const std::string& hostSubDir,
const std::string& hostName,
83 unsigned msxDirSector);
84 [[nodiscard]] DirIndex getFreeDirEntry(
unsigned msxDirSector);
85 [[nodiscard]] DirIndex findHostFileInDSK(std::string_view hostName);
86 [[nodiscard]]
bool checkFileUsedInDSK(std::string_view hostName);
87 [[nodiscard]]
unsigned nextMsxDirSector(
unsigned sector);
88 [[nodiscard]]
bool checkMSXFileExists(std::span<const char, 11> msxfilename,
89 unsigned msxDirSector);
90 void checkModifiedHostFiles();
93 void exportToHost(DirIndex dirIndex, DirIndex dirDirIndex);
94 void exportToHostDir (DirIndex dirIndex,
const std::string& hostName);
95 void exportToHostFile(DirIndex dirIndex,
const std::string& hostName);
96 [[nodiscard]]
unsigned findNextFreeCluster(
unsigned cluster);
97 [[nodiscard]]
unsigned findFirstFreeCluster();
98 [[nodiscard]]
unsigned getFreeCluster();
99 [[nodiscard]]
unsigned readFAT(
unsigned cluster);
100 void writeFAT12(
unsigned cluster,
unsigned val);
101 void exportFileFromFATChange(
unsigned cluster, std::span<SectorBuffer> oldFAT);
102 std::pair<unsigned, unsigned> getChainStart(
unsigned cluster);
103 [[nodiscard]]
bool isDirSector(
unsigned sector, DirIndex& dirDirIndex);
104 bool getDirEntryForCluster(
unsigned cluster,
105 DirIndex& dirIndex, DirIndex& dirDirIndex);
106 [[nodiscard]] DirIndex getDirEntryForCluster(
unsigned cluster);
107 void unmapHostFiles(
unsigned msxDirSector);
108 template<
typename FUNC>
bool scanMsxDirs(
109 FUNC func,
unsigned msxDirSector);
117 [[nodiscard]]
unsigned readFATHelper(std::span<const SectorBuffer> fat,
unsigned cluster)
const;
118 void writeFATHelper(std::span<SectorBuffer> fat,
unsigned cluster,
unsigned val)
const;
119 [[nodiscard]]
unsigned clusterToSector(
unsigned cluster)
const;
120 [[nodiscard]] std::pair<unsigned, unsigned> sectorToClusterOffset(
unsigned sector)
const;
121 [[nodiscard]]
unsigned sectorToCluster(
unsigned sector)
const;
126 const std::string hostDir;
139 const unsigned nofSectors;
140 const unsigned nofSectorsPerFat;
142 const unsigned firstSector2ndFAT;
143 const unsigned firstDirSector;
144 const unsigned firstDataSector;
145 const unsigned maxCluster;
148 std::vector<SectorBuffer> sectors;
void writeSectorImpl(size_t sector, const SectorBuffer &buf) override
bool isWriteProtectedImpl() const override
DirAsDSK(DiskChanger &diskChanger, CliComm &cliComm, const Filename &hostDir, SyncMode syncMode, BootSectorType bootSectorType)
void checkCaches() override
void readSectorImpl(size_t sector, SectorBuffer &buf) override
bool hasChanged() const override
Has the content of this disk changed, by some other means than the MSX writing to the disk.
This class represents a filename.
Abstract class for disk images that only represent the logical sector information (so not the raw tra...
This file implemented 3 utility functions:
bool operator==(const Event &x, const Event &y)