diff options
author | archshift <admin@archshift.com> | 2014-09-07 00:49:52 -0700 |
---|---|---|
committer | archshift <admin@archshift.com> | 2014-09-08 15:41:58 -0700 |
commit | 4ed24a06191a0dbf68bd72ad0fcc8d467b37f580 (patch) | |
tree | f3a1e6b49dc193153d039c1144b3789a9e7a7bc6 /src/common/string_util.cpp | |
parent | 335082e74e5f015450f1ad57cb90d1f8fd4afbdb (diff) |
loader.cpp: improved file extension checking, made Upper/LowerStr useful
Instead of forcibly taking the last 4 characters, it now finds the last extension separator (the period) and takes a substr of its location.
Diffstat (limited to 'src/common/string_util.cpp')
-rw-r--r-- | src/common/string_util.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index c1f22bda39..c489c868bc 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp @@ -18,19 +18,15 @@ #endif /// Make a string lowercase -void LowerStr(char* str) { - for (int i = 0; str[i]; i++) { - str[i] = tolower(str[ i ]); - } +std::string LowerStr(std::string str) { + std::transform(str.begin(), str.end(), str.begin(), ::tolower); + return str; } /// Make a string uppercase -void UpperStr(char* str) { - for (int i=0; i < strlen(str); i++) { - if(str[i] >= 'a' && str[i] <= 'z') { - str[i] &= 0xDF; - } - } +std::string UpperStr(std::string str) { + std::transform(str.begin(), str.end(), str.begin(), ::toupper); + return str; } // faster than sscanf |