bool LoadFile(std::string &filename, std::string *error_string) { INFO_LOG(LOADER,"Identifying file..."); // Note that this can modify filename! switch (Identify_File(filename)) { case FILETYPE_PSP_PBP_DIRECTORY: { std::string ebootFilename = filename + "/EBOOT.PBP"; FileInfo fileInfo; getFileInfo((filename + "/EBOOT.PBP").c_str(), &fileInfo); if (fileInfo.exists) { INFO_LOG(LOADER, "File is a PBP in a directory!"); std::string path = filename; size_t pos = path.find("/PSP/GAME/"); if (pos != std::string::npos) pspFileSystem.SetStartingDirectory("ms0:" + path.substr(pos)); return Load_PSP_ELF_PBP(ebootFilename.c_str(), error_string); } else { *error_string = "No EBOOT.PBP, misidentified game"; return false; } } case FILETYPE_PSP_PBP: case FILETYPE_PSP_ELF: { INFO_LOG(LOADER,"File is an ELF or loose PBP!"); return Load_PSP_ELF_PBP(filename.c_str(), error_string); } case FILETYPE_PSP_ISO: case FILETYPE_PSP_ISO_NP: case FILETYPE_PSP_DISC_DIRECTORY: // behaves the same as the mounting is already done by now pspFileSystem.SetStartingDirectory("disc0:/PSP_GAME/USRDIR"); return Load_PSP_ISO(filename.c_str(), error_string); case FILETYPE_ERROR: ERROR_LOG(LOADER, "Could not read file"); *error_string = "Error reading file"; break; case FILETYPE_ARCHIVE_RAR: *error_string = "File is compressed (RAR).\nPlease decompress first (try WinRAR)"; break; case FILETYPE_ARCHIVE_ZIP: *error_string = "File is compressed (ZIP).\nPlease decompress first (try WinRAR)"; break; case FILETYPE_UNKNOWN_BIN: case FILETYPE_UNKNOWN_ELF: case FILETYPE_UNKNOWN: default: ERROR_LOG(LOADER, "Failed to identify file"); *error_string = "Failed to identify file"; break; } return false; }
bool LoadFile(const char *filename, std::string *error_string) { INFO_LOG(LOADER,"Identifying file..."); switch (Identify_File(filename)) { case FILETYPE_PSP_PBP: case FILETYPE_PSP_ELF: { INFO_LOG(LOADER,"File is an ELF!"); std::string path = getDir(filename); // If loading from memstick... size_t pos = path.find("/PSP/GAME/"); if (pos != std::string::npos) pspFileSystem.SetStartingDirectory("ms0:" + path.substr(pos)); return Load_PSP_ELF_PBP(filename, error_string); } case FILETYPE_PSP_ISO: case FILETYPE_PSP_ISO_NP: pspFileSystem.SetStartingDirectory("disc0:/PSP_GAME/USRDIR"); return Load_PSP_ISO(filename, error_string); case FILETYPE_ERROR: ERROR_LOG(LOADER, "Could not read file"); *error_string = "Error reading file"; break; case FILETYPE_UNKNOWN_BIN: case FILETYPE_UNKNOWN_ELF: case FILETYPE_UNKNOWN: default: ERROR_LOG(LOADER, "Failed to identify file"); *error_string = "Failed to identify file"; break; } return false; }
bool LoadFile(FileLoader **fileLoaderPtr, std::string *error_string) { FileLoader *&fileLoader = *fileLoaderPtr; // Note that this can modify filename! switch (Identify_File(fileLoader)) { case FILETYPE_PSP_PBP_DIRECTORY: { // TODO: Perhaps we should/can never get here now? fileLoader = ResolveFileLoaderTarget(fileLoader); if (fileLoader->Exists()) { INFO_LOG(LOADER, "File is a PBP in a directory!"); IdentifiedFileType ebootType = Identify_File(fileLoader); if (ebootType == FILETYPE_PSP_ISO_NP) { InitMemoryForGameISO(fileLoader); pspFileSystem.SetStartingDirectory("disc0:/PSP_GAME/USRDIR"); return Load_PSP_ISO(fileLoader, error_string); } else if (ebootType == FILETYPE_PSP_PS1_PBP) { *error_string = "PS1 EBOOTs are not supported by PPSSPP."; return false; } std::string path = fileLoader->Path(); size_t pos = path.find("/PSP/GAME/"); if (pos != std::string::npos) { path = ResolvePBPDirectory(path); pspFileSystem.SetStartingDirectory("ms0:" + path.substr(pos)); } return Load_PSP_ELF_PBP(fileLoader, error_string); } else { *error_string = "No EBOOT.PBP, misidentified game"; return false; } } case FILETYPE_PSP_PBP: case FILETYPE_PSP_ELF: { INFO_LOG(LOADER,"File is an ELF or loose PBP!"); return Load_PSP_ELF_PBP(fileLoader, error_string); } case FILETYPE_PSP_ISO: case FILETYPE_PSP_ISO_NP: case FILETYPE_PSP_DISC_DIRECTORY: // behaves the same as the mounting is already done by now pspFileSystem.SetStartingDirectory("disc0:/PSP_GAME/USRDIR"); return Load_PSP_ISO(fileLoader, error_string); case FILETYPE_PSP_PS1_PBP: *error_string = "PS1 EBOOTs are not supported by PPSSPP."; break; case FILETYPE_ERROR: ERROR_LOG(LOADER, "Could not read file"); *error_string = "Error reading file"; break; case FILETYPE_ARCHIVE_RAR: #ifdef WIN32 *error_string = "RAR file detected (Require WINRAR)"; #else *error_string = "RAR file detected (Require UnRAR)"; #endif break; case FILETYPE_ARCHIVE_ZIP: #ifdef WIN32 *error_string = "ZIP file detected (Require WINRAR)"; #else *error_string = "ZIP file detected (Require UnRAR)"; #endif break; case FILETYPE_ARCHIVE_7Z: #ifdef WIN32 *error_string = "7z file detected (Require 7-Zip)"; #else *error_string = "7z file detected (Require 7-Zip)"; #endif break; case FILETYPE_ISO_MODE2: *error_string = "PSX game image detected."; break; case FILETYPE_NORMAL_DIRECTORY: ERROR_LOG(LOADER, "Just a directory."); *error_string = "Just a directory."; break; case FILETYPE_PPSSPP_SAVESTATE: *error_string = "This is a saved state, not a game."; // Actually, we could make it load it... break; case FILETYPE_PSP_SAVEDATA_DIRECTORY: *error_string = "This is save data, not a game."; // Actually, we could make it load it... break; case FILETYPE_UNKNOWN_BIN: case FILETYPE_UNKNOWN_ELF: case FILETYPE_UNKNOWN: default: ERROR_LOG(LOADER, "Failed to identify file"); *error_string = "Failed to identify file"; break; } return false; }
bool LoadFile(std::string &filename, std::string *error_string) { INFO_LOG(LOADER,"Identifying file..."); // Note that this can modify filename! switch (Identify_File(filename)) { case FILETYPE_PSP_PBP_DIRECTORY: { std::string ebootFilename = filename + "/EBOOT.PBP"; FileInfo fileInfo; getFileInfo((filename + "/EBOOT.PBP").c_str(), &fileInfo); if (fileInfo.exists) { INFO_LOG(LOADER, "File is a PBP in a directory!"); std::string ebootPath = filename + "/EBOOT.PBP"; IdentifiedFileType ebootType = Identify_File(ebootPath); if(ebootType == FILETYPE_PSP_ISO_NP) { InitMemoryForGameISO(ebootPath); pspFileSystem.SetStartingDirectory("disc0:/PSP_GAME/USRDIR"); return Load_PSP_ISO(filename.c_str(), error_string); } std::string path = filename; size_t pos = path.find("/PSP/GAME/"); if (pos != std::string::npos) pspFileSystem.SetStartingDirectory("ms0:" + path.substr(pos)); return Load_PSP_ELF_PBP(ebootFilename.c_str(), error_string); } else { *error_string = "No EBOOT.PBP, misidentified game"; return false; } } case FILETYPE_PSP_PBP: case FILETYPE_PSP_ELF: { INFO_LOG(LOADER,"File is an ELF or loose PBP!"); return Load_PSP_ELF_PBP(filename.c_str(), error_string); } case FILETYPE_PSP_ISO: case FILETYPE_PSP_ISO_NP: case FILETYPE_PSP_DISC_DIRECTORY: // behaves the same as the mounting is already done by now pspFileSystem.SetStartingDirectory("disc0:/PSP_GAME/USRDIR"); return Load_PSP_ISO(filename.c_str(), error_string); case FILETYPE_PSP_PS1_PBP: *error_string = "PS1 EBOOTs are not supported by PPSSPP."; break; case FILETYPE_ERROR: ERROR_LOG(LOADER, "Could not read file"); *error_string = "Error reading file"; break; case FILETYPE_ARCHIVE_RAR: #ifdef WIN32 *error_string = "File is compressed (RAR).\nPlease decompress first (try WinRAR)"; #else *error_string = "File is compressed (RAR).\nPlease decompress first (try UnRAR)"; #endif break; case FILETYPE_ARCHIVE_ZIP: #ifdef WIN32 *error_string = "File is compressed (ZIP).\nPlease decompress first (try WinRAR)"; #else *error_string = "File is compressed (ZIP).\nPlease decompress first (try UnRAR)"; #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."; break; case FILETYPE_UNKNOWN_BIN: case FILETYPE_UNKNOWN_ELF: case FILETYPE_UNKNOWN: default: ERROR_LOG(LOADER, "Failed to identify file"); *error_string = "Failed to identify file"; break; } return false; }