From 75e05bc441382db69c842a64c562738cb749214e Mon Sep 17 00:00:00 2001 From: "B. Stack" Date: Sun, 22 Jan 2023 13:56:55 -0500 Subject: add upstream 12.0 --- zen/file_path.cpp | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) (limited to 'zen/file_path.cpp') diff --git a/zen/file_path.cpp b/zen/file_path.cpp index 73a3e923..d06ab6bd 100644 --- a/zen/file_path.cpp +++ b/zen/file_path.cpp @@ -75,6 +75,13 @@ std::optional zen::getParentFolderPath(const Zstring& itemPath) } +Zstring zen::getFileExtension(const ZstringView filePath) +{ + const ZstringView fileName = afterLast(filePath, FILE_NAME_SEPARATOR, IfNotFoundReturn::all); + return Zstring(afterLast(fileName, Zstr('.'), IfNotFoundReturn::none)); +} + + Zstring zen::appendSeparator(Zstring path) //support rvalue references! { assert(!endsWith(path, FILE_NAME_SEPARATOR == Zstr('/') ? Zstr('\\' ) : Zstr('/' ))); @@ -116,25 +123,6 @@ Zstring zen::appendPath(const Zstring& basePath, const Zstring& relPath) } -Zstring zen::getFileExtension(const Zstring& filePath) -{ - //const Zstring fileName = afterLast(filePath, FILE_NAME_SEPARATOR, IfNotFoundReturn::all); - //return afterLast(fileName, Zstr('.'), IfNotFoundReturn::none); - - auto it = zen::findLast(filePath.begin(), filePath.end(), FILE_NAME_SEPARATOR); - if (it == filePath.end()) - it = filePath.begin(); - else - ++it; - - auto it2 = zen::findLast(it, filePath.end(), Zstr('.')); - if (it2 != filePath.end()) - ++it2; - - return Zstring(it2, filePath.end()); -} - - /* https://docs.microsoft.com/de-de/windows/desktop/Intl/handling-sorting-in-your-applications Perf test: compare strings 10 mio times; 64 bit build -- cgit