Make extension checks case-insensitive (#273)

## Summary

* Implement new `StringUtils::checkFileExtension` which does case
insensitive checking
* Move all checks over to this
This commit is contained in:
Dave Allie
2026-01-07 20:07:23 +10:00
committed by GitHub
parent 0cc2c64df2
commit 46fa186b82
7 changed files with 38 additions and 34 deletions

View File

@@ -5,6 +5,7 @@
#include "MappedInputManager.h"
#include "fontIds.h"
#include "util/StringUtils.h"
namespace {
constexpr int PAGE_ITEMS = 23;
@@ -50,9 +51,8 @@ void FileSelectionActivity::loadFiles() {
files.emplace_back(std::string(name) + "/");
} else {
auto filename = std::string(name);
std::string ext4 = filename.length() >= 4 ? filename.substr(filename.length() - 4) : "";
std::string ext5 = filename.length() >= 5 ? filename.substr(filename.length() - 5) : "";
if (ext5 == ".epub" || ext5 == ".xtch" || ext4 == ".xtc") {
if (StringUtils::checkFileExtension(filename, ".epub") || StringUtils::checkFileExtension(filename, ".xtch") ||
StringUtils::checkFileExtension(filename, ".xtc")) {
files.emplace_back(filename);
}
}