| 289 | } |
| 290 | |
| 291 | void checkConsistency() |
| 292 | { |
| 293 | /* Verify that we more-or-less understand the format by fscking the disk. */ |
| 294 | |
| 295 | std::vector<bool> bitmap(640); |
| 296 | for (const auto& i : directory) |
| 297 | { |
| 298 | const Dirent& dirent = *i.second; |
| 299 | if (!isValidFile(dirent)) |
| 300 | continue; |
| 301 | |
| 302 | int count = 0; |
| 303 | uint16_t sector = dirent.startSector; |
| 304 | while ((sector != 0xffff) && (sector != 0)) |
| 305 | { |
| 306 | if (bitmap[sector]) |
| 307 | std::cout << fmt::format( |
| 308 | "warning: sector {} appears to be multiply used\n", sector); |
| 309 | bitmap[sector] = true; |
| 310 | sector = allocationTable[sector]; |
| 311 | count++; |
| 312 | } |
| 313 | |
| 314 | if (count != dirent.sectorCount) |
| 315 | std::cout << fmt::format( |
| 316 | "Warning: file '{}' claims to be {} sectors long but its chain " |
| 317 | "is {}\n", |
| 318 | dirent.filename, |
| 319 | dirent.sectorCount, |
| 320 | count); |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | void listDirectory() |
| 325 | { |
no test coverage detected