mirror of
https://github.com/TomHarte/CLK.git
synced 2024-10-07 21:57:46 +00:00
Added a prefilter to catalogues to remove system files. They're not listed when you CAT
, so almost certainly aren't what a user would be expected to load.
This commit is contained in:
parent
9d9a1c341d
commit
48290a8bbe
@ -28,9 +28,17 @@ static std::string RunCommandFor(const Storage::Disk::CPM::File &file) {
|
|||||||
static void InspectDataCatalogue(
|
static void InspectDataCatalogue(
|
||||||
const Storage::Disk::CPM::Catalogue &catalogue,
|
const Storage::Disk::CPM::Catalogue &catalogue,
|
||||||
StaticAnalyser::Target &target) {
|
StaticAnalyser::Target &target) {
|
||||||
|
// Make a copy of all files and filter out any that are marked as system.
|
||||||
|
std::vector<Storage::Disk::CPM::File> candidate_files = catalogue.files;
|
||||||
|
candidate_files.erase(
|
||||||
|
std::remove_if(candidate_files.begin(), candidate_files.end(), [](const Storage::Disk::CPM::File &file) {
|
||||||
|
return file.system;
|
||||||
|
}),
|
||||||
|
candidate_files.end());
|
||||||
|
|
||||||
// If there's just one file, run that.
|
// If there's just one file, run that.
|
||||||
if(catalogue.files.size() == 1) {
|
if(candidate_files.size() == 1) {
|
||||||
target.loadingCommand = RunCommandFor(catalogue.files[0]);
|
target.loadingCommand = RunCommandFor(candidate_files[0]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,22 +50,22 @@ static void InspectDataCatalogue(
|
|||||||
size_t last_basic_file = 0;
|
size_t last_basic_file = 0;
|
||||||
size_t last_implicit_suffixed_file = 0;
|
size_t last_implicit_suffixed_file = 0;
|
||||||
|
|
||||||
for(size_t c = 0; c < catalogue.files.size(); c++) {
|
for(size_t c = 0; c < candidate_files.size(); c++) {
|
||||||
// Files with nothing but spaces in their name can't be loaded by the user, so disregard them.
|
// Files with nothing but spaces in their name can't be loaded by the user, so disregard them.
|
||||||
if(catalogue.files[c].type == " " && catalogue.files[c].name == " ")
|
if(candidate_files[c].type == " " && candidate_files[c].name == " ")
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Check for whether this is [potentially] BASIC.
|
// Check for whether this is [potentially] BASIC.
|
||||||
if(catalogue.files[c].data.size() >= 128 && !((catalogue.files[c].data[18] >> 1) & 7)) {
|
if(candidate_files[c].data.size() >= 128 && !((candidate_files[c].data[18] >> 1) & 7)) {
|
||||||
basic_files++;
|
basic_files++;
|
||||||
last_basic_file = c;
|
last_basic_file = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check suffix for emptiness.
|
// Check suffix for emptiness.
|
||||||
if(
|
if(
|
||||||
catalogue.files[c].type == " " ||
|
candidate_files[c].type == " " ||
|
||||||
strcmp_insensitive(catalogue.files[c].type.c_str(), "BAS") ||
|
strcmp_insensitive(candidate_files[c].type.c_str(), "BAS") ||
|
||||||
strcmp_insensitive(catalogue.files[c].type.c_str(), "BIN")
|
strcmp_insensitive(candidate_files[c].type.c_str(), "BIN")
|
||||||
) {
|
) {
|
||||||
implicit_suffixed_files++;
|
implicit_suffixed_files++;
|
||||||
last_implicit_suffixed_file = c;
|
last_implicit_suffixed_file = c;
|
||||||
@ -65,7 +73,7 @@ static void InspectDataCatalogue(
|
|||||||
}
|
}
|
||||||
if(basic_files == 1 || implicit_suffixed_files == 1) {
|
if(basic_files == 1 || implicit_suffixed_files == 1) {
|
||||||
size_t selected_file = (basic_files == 1) ? last_basic_file : last_implicit_suffixed_file;
|
size_t selected_file = (basic_files == 1) ? last_basic_file : last_implicit_suffixed_file;
|
||||||
target.loadingCommand = RunCommandFor(catalogue.files[selected_file]);
|
target.loadingCommand = RunCommandFor(candidate_files[selected_file]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user