mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-29 12:50:28 +00:00
Gives the FAT parser responsibility for right trims.
This commit is contained in:
parent
bcf483fb7e
commit
bae8bb0c00
@ -54,7 +54,7 @@ Analyser::Static::TargetList Analyser::Static::Enterprise::GetTargets(const Medi
|
||||
bool has_exdos_ini = false;
|
||||
bool did_pick_file = false;
|
||||
for(const auto &file: (*volume).root_directory) {
|
||||
if(insensitive_equal(file.name, "EXDOS ") && insensitive_equal(file.extension, "INI")) {
|
||||
if(insensitive_equal(file.name, "exdos") && insensitive_equal(file.extension, "ini")) {
|
||||
has_exdos_ini = true;
|
||||
break;
|
||||
}
|
||||
|
@ -32,6 +32,14 @@ int FAT::Volume::sector_for_cluster(uint16_t cluster) const {
|
||||
|
||||
namespace {
|
||||
|
||||
template <typename CharT> std::string trim(CharT start, CharT end) {
|
||||
std::string result(start, end);
|
||||
result.erase(std::find_if(result.rbegin(), result.rend(), [](unsigned char ch) {
|
||||
return !std::isspace(ch);
|
||||
}).base(), result.end());
|
||||
return result;
|
||||
}
|
||||
|
||||
FAT::Directory directory_from(const std::vector<uint8_t> &contents) {
|
||||
FAT::Directory result;
|
||||
|
||||
@ -49,8 +57,8 @@ FAT::Directory directory_from(const std::vector<uint8_t> &contents) {
|
||||
|
||||
// Otherwise create and populate a new entry.
|
||||
result.emplace_back();
|
||||
result.back().name = std::string(&contents[base], &contents[base+8]);
|
||||
result.back().extension = std::string(&contents[base+8], &contents[base+11]);
|
||||
result.back().name = trim(&contents[base], &contents[base+8]);
|
||||
result.back().extension = trim(&contents[base+8], &contents[base+11]);
|
||||
result.back().attributes = contents[base + 11];
|
||||
result.back().time = uint16_t(contents[base+22] | (contents[base+23] << 8));
|
||||
result.back().date = uint16_t(contents[base+24] | (contents[base+25] << 8));
|
||||
|
Loading…
Reference in New Issue
Block a user