sysupdater: don't do unnecessary work when parsing update

This commit is contained in:
Michael Scire
2020-06-26 05:05:24 -07:00
parent 4291d81642
commit d47e9ec9fd
3 changed files with 124 additions and 32 deletions

View File

@@ -196,6 +196,19 @@ namespace ams::mitm::sysupdater {
}
bool PathView::HasPrefix(std::string_view prefix) const {
return this->path.compare(0, prefix.length(), prefix) == 0;
}
bool PathView::HasSuffix(std::string_view suffix) const {
return this->path.compare(this->path.length() - suffix.length(), suffix.length(), suffix) == 0;
}
std::string_view PathView::GetFileName() const {
auto pos = this->path.find_last_of("/");
return pos != std::string_view::npos ? this->path.substr(pos + 1) : this->path;
}
Result MountSdCardContentMeta(const char *mount_name, const char *path) {
/* Sanitize input. */
/* NOTE: This is an internal API, so we won't bother with mount name sanitization. */