36 DirIndex(
unsigned sector_,
unsigned idx_)
37 : sector(sector_), idx(idx_) {}
38 friend bool operator==(
const DirIndex&
x,
const DirIndex& y) {
39 return (
x.sector == y.sector) &&
46 auto operator()(
const DirIndex& d)
const {
47 std::hash<unsigned> subHasher;
48 return 31 * subHasher(d.sector)
63 [[nodiscard]] SectorBuffer* fat();
64 [[nodiscard]] SectorBuffer* fat2();
65 [[nodiscard]] MSXDirEntry& msxDir(DirIndex dirIndex);
66 void writeFATSector (
unsigned sector,
const SectorBuffer& buf);
67 void writeDIRSector (
unsigned sector, DirIndex dirDirIndex,
68 const SectorBuffer& buf);
69 void writeDataSector(
unsigned sector,
const SectorBuffer& buf);
70 void writeDIREntry(DirIndex dirIndex, DirIndex dirDirIndex,
71 const MSXDirEntry& newEntry);
73 void checkDeletedHostFiles();
74 void deleteMSXFile(DirIndex dirIndex);
75 void deleteMSXFilesInDir(
unsigned msxDirSector);
76 void freeFATChain(
unsigned cluster);
77 void addNewHostFiles(
const std::string& hostSubDir,
unsigned msxDirSector);
78 void addNewDirectory(
const std::string& hostSubDir,
const std::string& hostName,
80 void addNewHostFile(
const std::string& hostSubDir,
const std::string& hostName,
82 [[nodiscard]] DirIndex fillMSXDirEntry(
83 const std::string& hostSubDir,
const std::string& hostName,
84 unsigned msxDirSector);
85 [[nodiscard]] DirIndex getFreeDirEntry(
unsigned msxDirSector);
86 [[nodiscard]] DirIndex findHostFileInDSK(std::string_view hostName);
87 [[nodiscard]]
bool checkFileUsedInDSK(std::string_view hostName);
88 [[nodiscard]]
unsigned nextMsxDirSector(
unsigned sector);
89 [[nodiscard]]
bool checkMSXFileExists(
const std::string& msxfilename,
90 unsigned msxDirSector);
91 void checkModifiedHostFiles();
94 void exportToHost(DirIndex dirIndex, DirIndex dirDirIndex);
95 void exportToHostDir (DirIndex dirIndex,
const std::string& hostName);
96 void exportToHostFile(DirIndex dirIndex,
const std::string& hostName);
97 [[nodiscard]]
unsigned findNextFreeCluster(
unsigned cluster);
98 [[nodiscard]]
unsigned findFirstFreeCluster();
99 [[nodiscard]]
unsigned getFreeCluster();
100 [[nodiscard]]
unsigned readFAT(
unsigned cluster);
101 void writeFAT12(
unsigned cluster,
unsigned val);
102 void exportFileFromFATChange(
unsigned cluster, SectorBuffer* oldFAT);
103 std::pair<unsigned, unsigned> getChainStart(
unsigned cluster);
104 [[nodiscard]]
bool isDirSector(
unsigned sector, DirIndex& dirDirIndex);
105 bool getDirEntryForCluster(
unsigned cluster,
106 DirIndex& dirIndex, DirIndex& dirDirIndex);
107 [[nodiscard]] DirIndex getDirEntryForCluster(
unsigned cluster);
108 void unmapHostFiles(
unsigned msxDirSector);
109 template<
typename FUNC>
bool scanMsxDirs(
110 FUNC func,
unsigned msxDirSector);
118 [[nodiscard]]
unsigned readFATHelper(
const SectorBuffer* fat,
unsigned cluster)
const;
119 void writeFATHelper(
SectorBuffer* fat,
unsigned cluster,
unsigned val)
const;
120 [[nodiscard]]
unsigned clusterToSector(
unsigned cluster)
const;
121 [[nodiscard]] std::pair<unsigned, unsigned> sectorToClusterOffset(
unsigned sector)
const;
122 [[nodiscard]]
unsigned sectorToCluster(
unsigned sector)
const;
127 const std::string hostDir;
140 const unsigned nofSectors;
141 const unsigned nofSectorsPerFat;
143 const unsigned firstSector2ndFAT;
144 const unsigned firstDirSector;
145 const unsigned firstDataSector;
146 const unsigned maxCluster;
149 std::vector<SectorBuffer> sectors;