mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-25 03:09:13 +01:00
commit
3bae3c8cd7
2 files changed
+32
-5
No files matched your search
+31
-5
@@ -35,9 +35,35 @@ IdentifiedFileType Identify_File(std::string &filename)
|
||||
return FILETYPE_ERROR;
|
||||
}
|
||||
|
||||
FileInfo info;
|
||||
if (!getFileInfo(filename.c_str(), &info)) {
|
||||
return FILETYPE_ERROR;
|
||||
}
|
||||
|
||||
std::string extension = filename.size() >= 5 ? filename.substr(filename.size() - 4) : "";
|
||||
if (!strcasecmp(extension.c_str(),".iso"))
|
||||
{
|
||||
// may be a psx iso, they have 2352 byte sectors. You never know what some people try to open
|
||||
if ((info.size % 2352) == 0)
|
||||
{
|
||||
FILE *f = File::OpenCFile(filename.c_str(), "rb");
|
||||
if (!f) {
|
||||
// File does not exists
|
||||
return FILETYPE_ERROR;
|
||||
}
|
||||
|
||||
unsigned char sync[12];
|
||||
fread(sync,1,12,f);
|
||||
fclose(f);
|
||||
|
||||
// each sector in a mode2 image starts with these 12 bytes
|
||||
if (memcmp(sync,"\x00\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\x00",12) == 0)
|
||||
{
|
||||
return FILETYPE_ISO_MODE2;
|
||||
}
|
||||
|
||||
// maybe it also just happened to have that size,
|
||||
}
|
||||
return FILETYPE_PSP_ISO;
|
||||
}
|
||||
else if (!strcasecmp(extension.c_str(),".cso"))
|
||||
@@ -45,12 +71,8 @@ IdentifiedFileType Identify_File(std::string &filename)
|
||||
return FILETYPE_PSP_ISO;
|
||||
}
|
||||
|
||||
// First, check if it's a directory with an EBOOT.PBP in it.
|
||||
FileInfo info;
|
||||
if (!getFileInfo(filename.c_str(), &info)) {
|
||||
return FILETYPE_ERROR;
|
||||
}
|
||||
|
||||
// First, check if it's a directory with an EBOOT.PBP in it.
|
||||
if (info.isDirectory) {
|
||||
if (filename.size() > 4) {
|
||||
FileInfo ebootInfo;
|
||||
@@ -218,6 +240,10 @@ bool LoadFile(std::string &filename, std::string *error_string) {
|
||||
#endif
|
||||
break;
|
||||
|
||||
case FILETYPE_ISO_MODE2:
|
||||
*error_string = "File is a MODE2 image. Are you trying to open a PSX game?";
|
||||
break;
|
||||
|
||||
case FILETYPE_NORMAL_DIRECTORY:
|
||||
ERROR_LOG(LOADER, "Just a directory.");
|
||||
*error_string = "Just a directory.";
|
||||
|
||||
@@ -36,6 +36,7 @@ enum IdentifiedFileType {
|
||||
FILETYPE_ARCHIVE_RAR,
|
||||
FILETYPE_ARCHIVE_ZIP,
|
||||
FILETYPE_PSP_PS1_PBP,
|
||||
FILETYPE_ISO_MODE2,
|
||||
|
||||
FILETYPE_NORMAL_DIRECTORY,
|
||||
|
||||
|
||||
Reference in new issue
Block a user