Remove expensive path.string() calls, UI changes

This commit is contained in:
Kyle Reed
2023-04-30 22:42:28 -07:00
parent 06643df6a5
commit bf4ed416bd
8 changed files with 254 additions and 147 deletions

View File

@@ -250,6 +250,16 @@ std::string filesystem_error::what() const {
}
}
path path::parent_path() const {
const auto t = filename().native();
const auto index = t.find_last_of(preferred_separator);
if( index == t.npos ) {
return *this;
} else {
return t.substr(0, index);
}
}
path path::extension() const {
const auto t = filename().native();
const auto index = t.find_last_of(u'.');
@@ -296,6 +306,10 @@ path& path::replace_extension(const path& replacement) {
return *this;
}
bool operator==(const path& lhs, const path& rhs) {
return lhs.native() == rhs.native();
}
bool operator<(const path& lhs, const path& rhs) {
return lhs.native() < rhs.native();
}
@@ -304,6 +318,12 @@ bool operator>(const path& lhs, const path& rhs) {
return lhs.native() > rhs.native();
}
path operator/(const path& lhs, const path& rhs) {
path result = lhs;
result /= rhs;
return result;
}
directory_iterator::directory_iterator(
std::filesystem::path path,
std::filesystem::path wild