summaryrefslogtreecommitdiff
path: root/src/common/string_util.cpp
diff options
context:
space:
mode:
authorGravatar archshift2014-09-07 00:49:52 -0700
committerGravatar archshift2014-09-08 15:41:58 -0700
commit4ed24a06191a0dbf68bd72ad0fcc8d467b37f580 (patch)
treef3a1e6b49dc193153d039c1144b3789a9e7a7bc6 /src/common/string_util.cpp
parentMerge pull request #95 from lioncash/disassembler (diff)
downloadyuzu-4ed24a06191a0dbf68bd72ad0fcc8d467b37f580.tar.gz
yuzu-4ed24a06191a0dbf68bd72ad0fcc8d467b37f580.tar.xz
yuzu-4ed24a06191a0dbf68bd72ad0fcc8d467b37f580.zip
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.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index c1f22bda3..c489c868b 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -18,19 +18,15 @@
18#endif 18#endif
19 19
20/// Make a string lowercase 20/// Make a string lowercase
21void LowerStr(char* str) { 21std::string LowerStr(std::string str) {
22 for (int i = 0; str[i]; i++) { 22 std::transform(str.begin(), str.end(), str.begin(), ::tolower);
23 str[i] = tolower(str[ i ]); 23 return str;
24 }
25} 24}
26 25
27/// Make a string uppercase 26/// Make a string uppercase
28void UpperStr(char* str) { 27std::string UpperStr(std::string str) {
29 for (int i=0; i < strlen(str); i++) { 28 std::transform(str.begin(), str.end(), str.begin(), ::toupper);
30 if(str[i] >= 'a' && str[i] <= 'z') { 29 return str;
31 str[i] &= 0xDF;
32 }
33 }
34} 30}
35 31
36// faster than sscanf 32// faster than sscanf