sysupdater: implement content meta mounting

This commit is contained in:
Michael Scire 2020-06-26 02:24:52 -07:00 committed by SciresM
parent 28a6bb713c
commit a6218ed814
7 changed files with 305 additions and 6 deletions

View file

@ -20,6 +20,54 @@
namespace ams::util {
template<typename T>
constexpr T ToLower(T c) {
return ('A' <= c && c <= 'Z') ? (c - 'A' + 'a') : c;
}
template<typename T>
constexpr T ToUpper(T c) {
return ('a' <= c && c <= 'z') ? (c - 'a' + 'A') : c;
}
template<typename T>
int Strncmp(const T *lhs, const T *rhs, int count) {
AMS_ASSERT(lhs != nullptr);
AMS_ASSERT(rhs != nullptr);
AMS_ABORT_UNLESS(count >= 0);
if (count == 0) {
return 0;
}
T l, r;
do {
l = *(lhs++);
r = *(rhs++);
} while (l && (l == r) && (--count));
return l - r;
}
template<typename T>
int Strnicmp(const T *lhs, const T *rhs, int count) {
AMS_ASSERT(lhs != nullptr);
AMS_ASSERT(rhs != nullptr);
AMS_ABORT_UNLESS(count >= 0);
if (count == 0) {
return 0;
}
T l, r;
do {
l = ::ams::util::ToLower(*(lhs++));
r = ::ams::util::ToLower(*(rhs++));
} while (l && (l == r) && (--count));
return l - r;
}
template<typename T>
constexpr int Strlcpy(T *dst, const T *src, int count) {
AMS_ASSERT(dst != nullptr);