1
0
mirror of https://github.com/TomHarte/CLK.git synced 2026-04-26 19:17:52 +00:00

Switches FileHolder to have a usage much closer to FILE *.

Thereby opens a route for file format implementations such as that appearing for CPC DSK that create an in-memory copy and perform a full rewrite.
This commit is contained in:
Thomas Harte
2017-11-02 22:32:00 -04:00
parent f807a6b608
commit e384c50580
28 changed files with 597 additions and 445 deletions
+4 -4
View File
@@ -21,13 +21,13 @@ SSD::SSD(const char *file_name) : MFMSectorDump(file_name) {
// very loose validation: the file needs to be a multiple of 256 bytes
// and not ungainly large
if(file_stats_.st_size & 255) throw ErrorNotSSD;
if(file_stats_.st_size < 512) throw ErrorNotSSD;
if(file_stats_.st_size > 800*256) throw ErrorNotSSD;
if(file_.stats().st_size & 255) throw ErrorNotSSD;
if(file_.stats().st_size < 512) throw ErrorNotSSD;
if(file_.stats().st_size > 800*256) throw ErrorNotSSD;
// this has two heads if the suffix is .dsd, one if it's .ssd
head_count_ = (tolower(file_name[strlen(file_name) - 3]) == 'd') ? 2 : 1;
track_count_ = static_cast<int>(file_stats_.st_size / (256 * 10));
track_count_ = static_cast<int>(file_.stats().st_size / (256 * 10));
if(track_count_ < 40) track_count_ = 40;
else if(track_count_ < 80) track_count_ = 80;