mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Optimize away a couple of existence checks
This commit is contained in:
parent
5d53e59c1d
commit
36079b86d0
3 changed files with 21 additions and 23 deletions
|
@ -602,19 +602,19 @@ int SavedataParam::Load(SceUtilitySavedataParam *param, const std::string &saveD
|
|||
return isRWMode ? SCE_UTILITY_SAVEDATA_ERROR_RW_NO_DATA : SCE_UTILITY_SAVEDATA_ERROR_LOAD_NO_DATA;
|
||||
}
|
||||
|
||||
if (!pspFileSystem.GetFileInfo(sfoPath).exists)
|
||||
// Load sfo
|
||||
if (!LoadSFO(param, dirPath)) {
|
||||
return isRWMode ? SCE_UTILITY_SAVEDATA_ERROR_RW_DATA_BROKEN : SCE_UTILITY_SAVEDATA_ERROR_LOAD_DATA_BROKEN;
|
||||
}
|
||||
|
||||
if (fileName != "" && !pspFileSystem.GetFileInfo(filePath).exists) {
|
||||
return isRWMode ? SCE_UTILITY_SAVEDATA_ERROR_RW_FILE_NOT_FOUND : SCE_UTILITY_SAVEDATA_ERROR_LOAD_FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
LoadSFO(param, dirPath); // Load sfo
|
||||
|
||||
// Don't know what it is, but PSP always respond this and this unlock some game
|
||||
param->bind = 1021;
|
||||
|
||||
// Load another files,seems these are required by some games, e.g. Fushigi no Dungeon Fuurai no Shiren 4 Plus.
|
||||
// Load another files, seems these are required by some games, e.g. Fushigi no Dungeon Fuurai no Shiren 4 Plus.
|
||||
|
||||
// Load ICON0.PNG
|
||||
LoadFile(dirPath, ICON0_FILENAME, ¶m->icon0FileData);
|
||||
|
@ -793,35 +793,33 @@ u32 SavedataParam::LoadNotCryptedSave(SceUtilitySavedataParam *param, u8 *data,
|
|||
return 0;
|
||||
}
|
||||
|
||||
void SavedataParam::LoadSFO(SceUtilitySavedataParam *param, const std::string& dirPath) {
|
||||
bool SavedataParam::LoadSFO(SceUtilitySavedataParam *param, const std::string& dirPath) {
|
||||
ParamSFOData sfoFile;
|
||||
std::string sfopath = dirPath+"/" + SFO_FILENAME;
|
||||
PSPFileInfo sfoInfo = pspFileSystem.GetFileInfo(sfopath);
|
||||
if (sfoInfo.exists) {
|
||||
// Read sfo
|
||||
std::vector<u8> sfoData;
|
||||
if (pspFileSystem.ReadEntireFile(sfopath, sfoData) >= 0) {
|
||||
sfoFile.ReadSFO(sfoData);
|
||||
std::string sfopath = dirPath + "/" + SFO_FILENAME;
|
||||
std::vector<u8> sfoData;
|
||||
if (pspFileSystem.ReadEntireFile(sfopath, sfoData) >= 0) {
|
||||
sfoFile.ReadSFO(sfoData);
|
||||
|
||||
// copy back info in request
|
||||
strncpy(param->sfoParam.title,sfoFile.GetValueString("TITLE").c_str(),128);
|
||||
strncpy(param->sfoParam.savedataTitle,sfoFile.GetValueString("SAVEDATA_TITLE").c_str(),128);
|
||||
strncpy(param->sfoParam.detail,sfoFile.GetValueString("SAVEDATA_DETAIL").c_str(),1024);
|
||||
param->sfoParam.parentalLevel = sfoFile.GetValueInt("PARENTAL_LEVEL");
|
||||
}
|
||||
// copy back info in request
|
||||
strncpy(param->sfoParam.title,sfoFile.GetValueString("TITLE").c_str(),128);
|
||||
strncpy(param->sfoParam.savedataTitle,sfoFile.GetValueString("SAVEDATA_TITLE").c_str(),128);
|
||||
strncpy(param->sfoParam.detail,sfoFile.GetValueString("SAVEDATA_DETAIL").c_str(),1024);
|
||||
param->sfoParam.parentalLevel = sfoFile.GetValueInt("PARENTAL_LEVEL");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<SaveSFOFileListEntry> SavedataParam::GetSFOEntries(const std::string &dirPath) {
|
||||
std::vector<SaveSFOFileListEntry> result;
|
||||
const std::string sfoPath = dirPath + "/" + SFO_FILENAME;
|
||||
if (!pspFileSystem.GetFileInfo(sfoPath).exists)
|
||||
return result;
|
||||
|
||||
ParamSFOData sfoFile;
|
||||
std::vector<u8> sfoData;
|
||||
if (pspFileSystem.ReadEntireFile(dirPath + "/" + SFO_FILENAME, sfoData) >= 0)
|
||||
if (pspFileSystem.ReadEntireFile(sfoPath, sfoData) >= 0) {
|
||||
sfoFile.ReadSFO(sfoData);
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
|
||||
const int FILE_LIST_COUNT_MAX = 99;
|
||||
u32 sfoFileListSize = 0;
|
||||
|
@ -1164,7 +1162,6 @@ int SavedataParam::GetSizes(SceUtilitySavedataParam *param)
|
|||
NotifyMemInfo(MemBlockFlags::WRITE, param->utilityData.ptr, sizeof(SceUtilitySavedataUsedDataInfo), "SavedataGetSizes");
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
bool SavedataParam::GetList(SceUtilitySavedataParam *param)
|
||||
|
|
|
@ -366,7 +366,7 @@ private:
|
|||
int LoadSaveData(SceUtilitySavedataParam *param, const std::string &saveDirName, const std::string& dirPath, bool secureMode);
|
||||
u32 LoadCryptedSave(SceUtilitySavedataParam *param, u8 *data, const u8 *saveData, int &saveSize, int prevCryptMode, const u8 *expectedHash, bool &saveDone);
|
||||
u32 LoadNotCryptedSave(SceUtilitySavedataParam *param, u8 *data, u8 *saveData, int &saveSize);
|
||||
void LoadSFO(SceUtilitySavedataParam *param, const std::string& dirPath);
|
||||
bool LoadSFO(SceUtilitySavedataParam *param, const std::string& dirPath);
|
||||
void LoadFile(const std::string& dirPath, const std::string& filename, PspUtilitySavedataFileData *fileData);
|
||||
|
||||
int DecryptSave(unsigned int mode, unsigned char *data, int *dataLen, int *alignedLen, unsigned char *cryptkey, const u8 *expectedHash);
|
||||
|
|
|
@ -598,6 +598,7 @@ int MetaFileSystem::ReadEntireFile(const std::string &filename, std::vector<u8>
|
|||
|
||||
if (result != dataSize)
|
||||
return SCE_KERNEL_ERROR_ERROR;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue