diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index d559ce9160..ad83a3c548 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -1092,14 +1092,42 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param) { hasMultipleFileName = true; saveDataList = new SaveFileInfo[saveDataListCount]; - + // get and stock file info for each file int realCount = 0; - for (int i = 0; i < saveDataListCount; i++) - { - // TODO: Maybe we should fill the list with existing files instead? - if (strcmp(saveNameListData[i], "<>") == 0) + for (int i = 0; i < saveDataListCount; i++) { + // "<>" means saveName can be anything... + if (strcmp(saveNameListData[i], "<>") == 0) { + std::string fileDataPath = ""; + auto allSaves = pspFileSystem.GetDirListing(savePath); + std::string gameName = GetGameName(param); + std::string saveName = ""; + for(auto it = allSaves.begin(); it != allSaves.end(); ++it) { + + if(strncmp(it->name.c_str(),gameName.c_str(),strlen(gameName.c_str())) == 0) { + saveName = it->name.substr(strlen(gameName.c_str())); + + if(IsInSaveDataList(saveName, realCount)) // Already in SaveDataList, skip... + continue; + + fileDataPath = savePath + it->name + "/" + param->fileName; + PSPFileInfo info = pspFileSystem.GetFileInfo(fileDataPath); + if (info.exists) { + SetFileInfo(realCount, info, saveName); + DEBUG_LOG(SCEUTILITY,"%s Exist",fileDataPath.c_str()); + ++realCount; + } else { + if (listEmptyFile) { + ClearFileInfo(saveDataList[realCount], saveName); + DEBUG_LOG(SCEUTILITY,"Don't Exist"); + ++realCount; + } + } + break; + } + } continue; + } DEBUG_LOG(SCEUTILITY,"Name : %s",saveNameListData[i]); @@ -1450,3 +1478,10 @@ bool SavedataParam::IsSaveEncrypted(SceUtilitySavedataParam* param, const std::s return isCrypted; } +bool SavedataParam::IsInSaveDataList(std::string saveName, int count) { + for(int i = 0; i < count; ++i) { + if(strcmp(saveDataList[i].saveName.c_str(),saveName.c_str()) == 0) + return true; + } + return false; +} diff --git a/Core/Dialog/SavedataParam.h b/Core/Dialog/SavedataParam.h index e45c66fa6e..540712b216 100644 --- a/Core/Dialog/SavedataParam.h +++ b/Core/Dialog/SavedataParam.h @@ -303,6 +303,7 @@ public: int GetFilesList(SceUtilitySavedataParam* param); bool GetSize(SceUtilitySavedataParam* param); bool IsSaveEncrypted(SceUtilitySavedataParam* param, const std::string &saveDirName); + bool IsInSaveDataList(std::string saveName, int count); std::string GetGameName(SceUtilitySavedataParam* param); std::string GetSaveName(SceUtilitySavedataParam* param);