diff --git a/StaticAnalyser/AmstradCPC/StaticAnalyser.cpp b/StaticAnalyser/AmstradCPC/StaticAnalyser.cpp index ebce0c606..dc70d5f8f 100644 --- a/StaticAnalyser/AmstradCPC/StaticAnalyser.cpp +++ b/StaticAnalyser/AmstradCPC/StaticAnalyser.cpp @@ -50,14 +50,35 @@ static std::string RunCommandFor(const Storage::Disk::CPM::File &file) { static void InspectDataCatalogue( const Storage::Disk::CPM::Catalogue &catalogue, StaticAnalyser::Target &target) { - // Make a copy of all files and filter out any that are marked as system. std::vector candidate_files = catalogue.files; + + // Remove all files with untypable characters. candidate_files.erase( std::remove_if(candidate_files.begin(), candidate_files.end(), [](const Storage::Disk::CPM::File &file) { - return file.system; + for(auto c : file.name) { + if(c < 32) return true; + } + return false; }), candidate_files.end()); + // If that leaves a mix of 'system' (i.e. hidden) and non-system files, remove the system files. + bool are_all_system = true; + for(auto &file : candidate_files) { + if(!file.system) { + are_all_system = false; + break; + } + } + + if(!are_all_system) { + 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(candidate_files.size() == 1) { target.loadingCommand = RunCommandFor(candidate_files[0]); @@ -153,6 +174,15 @@ void StaticAnalyser::AmstradCPC::AddTargets(const Media &media, std::list system_catalogue = Storage::Disk::CPM::GetCatalogue(target.media.disks.front(), system_format); std::unique_ptr data_catalogue = Storage::Disk::CPM::GetCatalogue(target.media.disks.front(), data_format); if(data_catalogue) {