summaryrefslogtreecommitdiffstats
path: root/src/core/loader
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2014-09-11 06:04:36 +0200
committerbunnei <bunneidev@gmail.com>2014-09-11 06:04:36 +0200
commit532a9e80a0bd242d2937335063b719130405d6bc (patch)
tree84fe1f054b62edc488a7a9e80eb8f79b2dd05cd0 /src/core/loader
parentMerge pull request #103 from archshift/prune (diff)
parentMoved common_types::Rect from common to Common namespace (diff)
downloadyuzu-532a9e80a0bd242d2937335063b719130405d6bc.tar
yuzu-532a9e80a0bd242d2937335063b719130405d6bc.tar.gz
yuzu-532a9e80a0bd242d2937335063b719130405d6bc.tar.bz2
yuzu-532a9e80a0bd242d2937335063b719130405d6bc.tar.lz
yuzu-532a9e80a0bd242d2937335063b719130405d6bc.tar.xz
yuzu-532a9e80a0bd242d2937335063b719130405d6bc.tar.zst
yuzu-532a9e80a0bd242d2937335063b719130405d6bc.zip
Diffstat (limited to 'src/core/loader')
-rw-r--r--src/core/loader/loader.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp
index 5cbb26f54..577a2297a 100644
--- a/src/core/loader/loader.cpp
+++ b/src/core/loader/loader.cpp
@@ -25,22 +25,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")) {
- return FileType::ELF; // TODO(bunnei): Do some filetype checking :p
- }
- else if (!strcasecmp(extension.c_str(), ".axf")) {
- return FileType::ELF; // TODO(bunnei): Do some filetype checking :p
- }
- else if (!strcasecmp(extension.c_str(), ".cxi")) {
- return FileType::CXI; // TODO(bunnei): Do some filetype checking :p
- }
- else if (!strcasecmp(extension.c_str(), ".cci")) {
- return FileType::CCI; // TODO(bunnei): Do some filetype checking :p
- }
- else if (!strcasecmp(extension.c_str(), ".bin")) {
- return FileType::BIN; // TODO(bunnei): Do some filetype checking :p
+ size_t extension_loc = filename.find_last_of('.');
+ if (extension_loc == std::string::npos)
+ return FileType::Unknown;
+ std::string extension = Common::ToLower(filename.substr(extension_loc));
+
+ // TODO(bunnei): Do actual filetype checking instead of naively checking the extension
+ if (extension == ".elf") {
+ return FileType::ELF;
+ } else if (extension == ".axf") {
+ return FileType::ELF;
+ } else if (extension == ".cxi") {
+ return FileType::CXI;
+ } else if (extension == ".cci") {
+ return FileType::CCI;
+ } else if (extension == ".bin") {
+ return FileType::BIN;
}
return FileType::Unknown;
}