summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorarchshift <admin@archshift.com>2014-09-07 09:49:52 +0200
committerarchshift <admin@archshift.com>2014-09-09 00:41:58 +0200
commit4ed24a06191a0dbf68bd72ad0fcc8d467b37f580 (patch)
treef3a1e6b49dc193153d039c1144b3789a9e7a7bc6
parentMerge pull request #95 from lioncash/disassembler (diff)
downloadyuzu-4ed24a06191a0dbf68bd72ad0fcc8d467b37f580.tar
yuzu-4ed24a06191a0dbf68bd72ad0fcc8d467b37f580.tar.gz
yuzu-4ed24a06191a0dbf68bd72ad0fcc8d467b37f580.tar.bz2
yuzu-4ed24a06191a0dbf68bd72ad0fcc8d467b37f580.tar.lz
yuzu-4ed24a06191a0dbf68bd72ad0fcc8d467b37f580.tar.xz
yuzu-4ed24a06191a0dbf68bd72ad0fcc8d467b37f580.tar.zst
yuzu-4ed24a06191a0dbf68bd72ad0fcc8d467b37f580.zip
-rw-r--r--src/common/string_util.cpp16
-rw-r--r--src/common/string_util.h5
-rw-r--r--src/core/loader/loader.cpp14
3 files changed, 17 insertions, 18 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 @@
#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
diff --git a/src/common/string_util.h b/src/common/string_util.h
index ba4cd363e..b1118816e 100644
--- a/src/common/string_util.h
+++ b/src/common/string_util.h
@@ -13,10 +13,11 @@
#include "common/common.h"
/// Make a string lowercase
-void LowerStr(char* str);
+
+std::string LowerStr(std::string str);
/// Make a string uppercase
-void UpperStr(char* str);
+std::string UpperStr(std::string str);
std::string StringFromFormat(const char* format, ...);
// Cheap!
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp
index 365f5a277..ce1154b79 100644
--- a/src/core/loader/loader.cpp
+++ b/src/core/loader/loader.cpp
@@ -26,21 +26,23 @@ FileType IdentifyFile(const std::string &filename) {
ERROR_LOG(LOADER, "invalid filename %s", filename.c_str());
return FileType::Error;
}
- std::string extension = filename.size() >= 5 ? filename.substr(filename.size() - 4) : "";
- if (!strcasecmp(extension.c_str(), ".elf")) {
+ size_t extension_loc = filename.find_last_of('.');
+ std::string extension = extension_loc != std::string::npos ? filename.substr(extension_loc) : "";
+
+ if (LowerStr(extension) == ".elf") {
return FileType::ELF; // TODO(bunnei): Do some filetype checking :p
}
- else if (!strcasecmp(extension.c_str(), ".axf")) {
+ else if (LowerStr(extension) == ".axf") {
return FileType::ELF; // TODO(bunnei): Do some filetype checking :p
}
- else if (!strcasecmp(extension.c_str(), ".cxi")) {
+ else if (LowerStr(extension) == ".cxi") {
return FileType::CXI; // TODO(bunnei): Do some filetype checking :p
}
- else if (!strcasecmp(extension.c_str(), ".cci")) {
+ else if (LowerStr(extension) == ".cci") {
return FileType::CCI; // TODO(bunnei): Do some filetype checking :p
}
- else if (!strcasecmp(extension.c_str(), ".bin")) {
+ else if (LowerStr(extension) == ".bin") {
return FileType::BIN; // TODO(bunnei): Do some filetype checking :p
}
return FileType::Unknown;