#pragma once
#include <algorithm>
#include <cctype>
#include <string>
namespace whiteout::storages::common {
inline std::string toLower(const std::string& s) {
std::string r = s;
std::transform(r.begin(), r.end(), r.begin(),
[](unsigned char c) { return char(std::tolower(c)); });
return r;
}
inline std::string normalizeCascPath(const std::string& s) {
std::string r = s;
for (auto& c : r) {
if (c == '/')
c = '\\';
c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
}
size_t start = 0;
while (start < r.size() && r[start] == '\\')
++start;
size_t end = r.size();
while (end > start && r[end - 1] == '\\')
--end;
if (start == 0 && end == r.size())
return r;
return r.substr(start, end - start);
}
}