diff options
author | Daniel Wilhelm <shieldwed@outlook.com> | 2018-07-29 21:45:13 -0700 |
---|---|---|
committer | Daniel Wilhelm <shieldwed@outlook.com> | 2018-07-29 21:45:13 -0700 |
commit | 06c99e6c91d87a91f3e54191670d23e3f4d132b9 (patch) | |
tree | a2c82149d6fe802c68365f73e11f3c241c95ef3d /zen/zstring.h | |
parent | 10.1 (diff) | |
download | FreeFileSync-06c99e6c91d87a91f3e54191670d23e3f4d132b9.tar.gz FreeFileSync-06c99e6c91d87a91f3e54191670d23e3f4d132b9.tar.bz2 FreeFileSync-06c99e6c91d87a91f3e54191670d23e3f4d132b9.zip |
10.2
Diffstat (limited to 'zen/zstring.h')
-rwxr-xr-x | zen/zstring.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/zen/zstring.h b/zen/zstring.h index cb19318c..026737da 100755 --- a/zen/zstring.h +++ b/zen/zstring.h @@ -18,7 +18,7 @@ //a high-performance string for interfacing with native OS APIs in multithreaded contexts using Zstring = zen::Zbase<Zchar>; - //for special UI-contexts: guaranteed exponential growth + ref-counting +//for special UI-contexts: guaranteed exponential growth + ref-counting using Zstringw = zen::Zbase<wchar_t>; @@ -65,8 +65,20 @@ Zstring appendSeparator(Zstring path) //support rvalue references! inline Zstring getFileExtension(const Zstring& filePath) { - const Zstring shortName = afterLast(filePath, FILE_NAME_SEPARATOR, zen::IF_MISSING_RETURN_ALL); - return afterLast(shortName, Zchar('.'), zen::IF_MISSING_RETURN_NONE); + //const Zstring fileName = afterLast(filePath, FILE_NAME_SEPARATOR, zen::IF_MISSING_RETURN_ALL); + //return afterLast(fileName, Zstr('.'), zen::IF_MISSING_RETURN_NONE); + + auto it = zen::find_last(filePath.begin(), filePath.end(), FILE_NAME_SEPARATOR); + if (it == filePath.end()) + it = filePath.begin(); + else + ++it; + + auto it2 = zen::find_last(it, filePath.end(), Zstr('.')); + if (it2 != filePath.end()) + ++it2; + + return Zstring(it2, filePath.end()); } |