mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-07 05:30:30 +00:00
Adjusted rules so as not to type unnecessary spaces in the name, and to include the extension if AMSDOS won't imply it.
This commit is contained in:
parent
b476f06524
commit
76c6b715a2
@ -21,8 +21,30 @@ static bool strcmp_insensitive(const char *a, const char *b) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool is_implied_extension(const std::string &extension) {
|
||||||
|
return
|
||||||
|
extension == " " ||
|
||||||
|
strcmp_insensitive(extension.c_str(), "BAS") ||
|
||||||
|
strcmp_insensitive(extension.c_str(), "BIN");
|
||||||
|
}
|
||||||
|
|
||||||
static std::string RunCommandFor(const Storage::Disk::CPM::File &file) {
|
static std::string RunCommandFor(const Storage::Disk::CPM::File &file) {
|
||||||
return "run\"" + file.name + "\n";
|
// Trim spaces from the name.
|
||||||
|
std::string name = file.name;
|
||||||
|
name.erase(std::find_if(name.rbegin(), name.rend(), [](int ch) {
|
||||||
|
return !std::isspace(ch);
|
||||||
|
}).base(), name.end());
|
||||||
|
|
||||||
|
// Form the basic command.
|
||||||
|
std::string command = "run\"" + name;
|
||||||
|
|
||||||
|
// Consider whether the extension is required.
|
||||||
|
if(!is_implied_extension(file.type)) {
|
||||||
|
command += "." + file.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a newline and return.
|
||||||
|
return command + "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
static void InspectDataCatalogue(
|
static void InspectDataCatalogue(
|
||||||
@ -62,11 +84,7 @@ static void InspectDataCatalogue(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check suffix for emptiness.
|
// Check suffix for emptiness.
|
||||||
if(
|
if(is_implied_extension(candidate_files[c].type)) {
|
||||||
candidate_files[c].type == " " ||
|
|
||||||
strcmp_insensitive(candidate_files[c].type.c_str(), "BAS") ||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user