refactor(file): overhaul filesystem for better accuracy, add some new features too

This commit is contained in:
phaneron 2025-03-15 22:23:38 -04:00
parent e674242b47
commit 5d96890167
111 changed files with 3708 additions and 3420 deletions

72
bc/file/SimpleGlob.cpp Normal file
View file

@ -0,0 +1,72 @@
#include "bc/file/SimpleGlob.hpp"
#include <cstdint>
#include <cctype>
namespace Blizzard {
namespace File {
bool SimpleGlob(const char* name, const char* pattern) {
auto p = pattern;
auto n = name;
while (true) {
if (*p == '\0') {
return !*n;
}
if (!*n && *p != '*') {
return false;
}
if (*p == '*') {
break;
}
if (*p == '?') {
if (!*n) {
return false;
}
} else {
if (*p == '\\' && p[1]) {
p++;
}
if (*p != *n) {
if (tolower(static_cast<uint8_t>(*n)) != tolower(static_cast<uint8_t>(*p))) {
return false;
}
}
}
n++;
p++;
}
while (*p == '*') {
p++;
}
if (*p) {
if (*p != '?' && *p != '\\') {
if (!*n) {
return false;
}
while (*p != *n) {
if (!*++n) {
return false;
}
}
}
if (!*n) {
return false;
}
while (!SimpleGlob(n, p)) {
n++;
if (*n == '\0') {
return false;
}
}
}
return true;
}
} // namespace File
} // namespace Blizzard