mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Loaders: Remove fileLoader->Extension().
This commit is contained in:
parent
9480b6672b
commit
939dd200c3
4 changed files with 15 additions and 32 deletions
|
@ -72,8 +72,8 @@ IdentifiedFileType Identify_File(FileLoader *fileLoader) {
|
|||
return IdentifiedFileType::ERROR_IDENTIFYING;
|
||||
}
|
||||
|
||||
std::string extension = fileLoader->Extension();
|
||||
if (!strcasecmp(extension.c_str(), ".iso")) {
|
||||
std::string extension = "." + File::GetFileExtension(fileLoader->GetPath());
|
||||
if (extension == ".iso") {
|
||||
// may be a psx iso, they have 2352 byte sectors. You never know what some people try to open
|
||||
if ((fileLoader->FileSize() % 2352) == 0) {
|
||||
unsigned char sync[12];
|
||||
|
@ -87,11 +87,11 @@ IdentifiedFileType Identify_File(FileLoader *fileLoader) {
|
|||
// maybe it also just happened to have that size,
|
||||
}
|
||||
return IdentifiedFileType::PSP_ISO;
|
||||
} else if (!strcasecmp(extension.c_str(), ".cso")) {
|
||||
} else if (extension == ".cso") {
|
||||
return IdentifiedFileType::PSP_ISO;
|
||||
} else if (!strcasecmp(extension.c_str(), ".ppst")) {
|
||||
} else if (extension == ".ppst") {
|
||||
return IdentifiedFileType::PPSSPP_SAVESTATE;
|
||||
} else if (!strcasecmp(extension.c_str(), ".ppdmp")) {
|
||||
} else if (extension == ".ppdmp") {
|
||||
char data[8]{};
|
||||
fileLoader->ReadAt(0, 8, data);
|
||||
if (memcmp(data, "PPSSPPGE", 8) == 0) {
|
||||
|
@ -144,14 +144,12 @@ IdentifiedFileType Identify_File(FileLoader *fileLoader) {
|
|||
if (id == 'FLE\x7F') {
|
||||
std::string filename = fileLoader->GetPath();
|
||||
// There are a few elfs misnamed as pbp (like Trig Wars), accept that.
|
||||
if (!strcasecmp(extension.c_str(), ".plf") || strstr(filename.c_str(),"BOOT.BIN") ||
|
||||
!strcasecmp(extension.c_str(), ".elf") || !strcasecmp(extension.c_str(), ".prx") ||
|
||||
!strcasecmp(extension.c_str(), ".pbp")) {
|
||||
if (extension == ".plf" || strstr(filename.c_str(), "BOOT.BIN") ||
|
||||
extension == ".elf" || extension == ".prx" || extension == ".pbp") {
|
||||
return IdentifiedFileType::PSP_ELF;
|
||||
}
|
||||
return IdentifiedFileType::UNKNOWN_ELF;
|
||||
}
|
||||
else if (id == 'PBP\x00') {
|
||||
} else if (id == 'PBP\x00') {
|
||||
// Do this PS1 eboot check FIRST before checking other eboot types.
|
||||
// It seems like some are malformed and slip through the PSAR check below.
|
||||
PBPReader pbp(fileLoader);
|
||||
|
@ -184,21 +182,20 @@ IdentifiedFileType Identify_File(FileLoader *fileLoader) {
|
|||
return IdentifiedFileType::PSP_PBP_DIRECTORY;
|
||||
}
|
||||
return IdentifiedFileType::PSP_PBP;
|
||||
}
|
||||
else if (!strcasecmp(extension.c_str(),".pbp")) {
|
||||
} else if (extension == ".pbp") {
|
||||
ERROR_LOG(LOADER, "A PBP with the wrong magic number?");
|
||||
return IdentifiedFileType::PSP_PBP;
|
||||
} else if (!strcasecmp(extension.c_str(),".bin")) {
|
||||
} else if (extension == ".bin") {
|
||||
return IdentifiedFileType::UNKNOWN_BIN;
|
||||
} else if (!strcasecmp(extension.c_str(),".zip")) {
|
||||
} else if (extension == ".zip") {
|
||||
return IdentifiedFileType::ARCHIVE_ZIP;
|
||||
} else if (!strcasecmp(extension.c_str(),".rar")) {
|
||||
} else if (extension == ".rar") {
|
||||
return IdentifiedFileType::ARCHIVE_RAR;
|
||||
} else if (!strcasecmp(extension.c_str(),".r00")) {
|
||||
} else if (extension == ".r00") {
|
||||
return IdentifiedFileType::ARCHIVE_RAR;
|
||||
} else if (!strcasecmp(extension.c_str(),".r01")) {
|
||||
} else if (extension == ".r01") {
|
||||
return IdentifiedFileType::ARCHIVE_RAR;
|
||||
} else if (!extension.empty() && !strcasecmp(extension.substr(1).c_str(), ".7z")) {
|
||||
} else if (extension == ".7z") {
|
||||
return IdentifiedFileType::ARCHIVE_7Z;
|
||||
}
|
||||
return IdentifiedFileType::UNKNOWN;
|
||||
|
|
|
@ -75,15 +75,6 @@ public:
|
|||
virtual bool IsDirectory() = 0;
|
||||
virtual s64 FileSize() = 0;
|
||||
virtual std::string GetPath() const = 0;
|
||||
virtual std::string Extension() {
|
||||
const std::string filename = GetPath();
|
||||
size_t pos = filename.find_last_of('.');
|
||||
if (pos == filename.npos) {
|
||||
return "";
|
||||
} else {
|
||||
return filename.substr(pos);
|
||||
}
|
||||
}
|
||||
virtual size_t ReadAt(s64 absolutePos, size_t bytes, size_t count, void *data, Flags flags = Flags::NONE) = 0;
|
||||
virtual size_t ReadAt(s64 absolutePos, size_t bytes, void *data, Flags flags = Flags::NONE) {
|
||||
return ReadAt(absolutePos, 1, bytes, data, flags);
|
||||
|
|
|
@ -135,10 +135,6 @@ std::string StorageFileLoader::GetPath() const {
|
|||
return path_;
|
||||
}
|
||||
|
||||
std::string StorageFileLoader::Extension() {
|
||||
return "." + File::GetFileExtension(path_);
|
||||
}
|
||||
|
||||
void StorageFileLoader::EnsureOpen() {
|
||||
while (size_ == -1)
|
||||
Sleep(50);
|
||||
|
|
|
@ -25,7 +25,6 @@ public:
|
|||
bool IsDirectory() override;
|
||||
s64 FileSize() override;
|
||||
std::string GetPath() const override;
|
||||
std::string Extension() override;
|
||||
|
||||
size_t ReadAt(s64 absolutePos, size_t bytes, size_t count, void *data, Flags flags = Flags::NONE) override;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue