33 [[nodiscard]]
bool hasChanged()
const override;
39 DirIndex(
unsigned sector_,
unsigned idx_)
40 : sector(sector_), idx(idx_) {}
41 [[nodiscard]]
constexpr bool operator==(
const DirIndex&)
const =
default;
47 auto operator()(
const DirIndex& d)
const {
48 std::hash<unsigned> subHasher;
49 return 31 * subHasher(d.sector)
64 [[nodiscard]] std::span<SectorBuffer> fat();
65 [[nodiscard]] std::span<SectorBuffer> fat2();
66 [[nodiscard]] MSXDirEntry& msxDir(DirIndex dirIndex);
67 void writeFATSector (
unsigned sector,
const SectorBuffer& buf);
68 void writeDIRSector (
unsigned sector, DirIndex dirDirIndex,
69 const SectorBuffer& buf);
70 void writeDataSector(
unsigned sector,
const SectorBuffer& buf);
71 void writeDIREntry(DirIndex dirIndex, DirIndex dirDirIndex,
72 const MSXDirEntry& newEntry);
74 void checkDeletedHostFiles();
75 void deleteMSXFile(DirIndex dirIndex);
76 void deleteMSXFilesInDir(
unsigned msxDirSector);
77 void freeFATChain(
unsigned cluster);
78 void addNewHostFiles(
const std::string& hostSubDir,
unsigned msxDirSector);
79 void addNewDirectory(
const std::string& hostSubDir,
const std::string& hostName,
81 void addNewHostFile(
const std::string& hostSubDir,
const std::string& hostName,
83 [[nodiscard]] DirIndex fillMSXDirEntry(
84 const std::string& hostSubDir,
const std::string& hostName,
85 unsigned msxDirSector);
86 [[nodiscard]] DirIndex getFreeDirEntry(
unsigned msxDirSector);
87 [[nodiscard]] DirIndex findHostFileInDSK(std::string_view hostName)
const;
88 [[nodiscard]]
bool checkFileUsedInDSK(std::string_view hostName)
const;
89 [[nodiscard]]
unsigned nextMsxDirSector(
unsigned sector);
90 [[nodiscard]]
bool checkMSXFileExists(std::span<const char, 11> msxfilename,
91 unsigned msxDirSector);
92 void checkModifiedHostFiles();
95 void exportToHost(DirIndex dirIndex, DirIndex dirDirIndex);
96 void exportToHostDir (DirIndex dirIndex,
const std::string& hostName);
97 void exportToHostFile(DirIndex dirIndex,
const std::string& hostName);
98 [[nodiscard]]
unsigned findNextFreeCluster(
unsigned cluster);
99 [[nodiscard]]
unsigned findFirstFreeCluster();
100 [[nodiscard]]
unsigned getFreeCluster();
101 [[nodiscard]]
unsigned readFAT(
unsigned cluster);
102 void writeFAT12(
unsigned cluster,
unsigned val);
103 void exportFileFromFATChange(
unsigned cluster, std::span<SectorBuffer> oldFAT);
104 std::pair<unsigned, unsigned> getChainStart(
unsigned cluster);
105 [[nodiscard]] std::optional<DirIndex> isDirSector(
unsigned sector);
107 struct DirEntryForClusterResult {
109 DirIndex dirDirIndex;
111 [[nodiscard]] std::optional<DirEntryForClusterResult> getDirEntryForCluster(
unsigned cluster);
113 void unmapHostFiles(
unsigned msxDirSector);
114 template<
typename FUNC>
bool scanMsxDirs(
115 FUNC&& func,
unsigned msxDirSector);
123 [[nodiscard]]
unsigned readFATHelper(std::span<const SectorBuffer> fat,
unsigned cluster)
const;
124 void writeFATHelper(std::span<SectorBuffer> fat,
unsigned cluster,
unsigned val)
const;
125 [[nodiscard]]
unsigned clusterToSector(
unsigned cluster)
const;
126 [[nodiscard]] std::pair<unsigned, unsigned> sectorToClusterOffset(
unsigned sector)
const;
127 [[nodiscard]]
unsigned sectorToCluster(
unsigned sector)
const;
132 const std::string hostDir;
135 EmuTime lastAccess = EmuTime::zero();
145 const unsigned nofSectors;
146 const unsigned nofSectorsPerFat;
148 const unsigned firstSector2ndFAT;
149 const unsigned firstDirSector;
150 const unsigned firstDataSector;
151 const unsigned maxCluster;
154 std::vector<SectorBuffer> sectors;