From e699eb95b21dd18de2330f587df0a33de846d117 Mon Sep 17 00:00:00 2001 From: shenweip Date: Sun, 27 Oct 2013 19:03:14 +0800 Subject: [PATCH 1/2] Add support for saveNameListData "<>". --- Core/Dialog/SavedataParam.cpp | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index d559ce9160..dbd19a86c9 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -1092,14 +1092,37 @@ 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) { + fileDataPath = savePath + it->name + "/" + param->fileName; + saveName = it->name.substr(strlen(gameName.c_str())); + 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]); From f4b60f22b0a64d43a82c0e99c321743a1bfdaec6 Mon Sep 17 00:00:00 2001 From: shenweip Date: Mon, 28 Oct 2013 00:07:32 +0800 Subject: [PATCH 2/2] Add a check to avoid the same savedatas are set into SaveDataList. --- Core/Dialog/SavedataParam.cpp | 14 +++++++++++++- Core/Dialog/SavedataParam.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Core/Dialog/SavedataParam.cpp b/Core/Dialog/SavedataParam.cpp index dbd19a86c9..ad83a3c548 100644 --- a/Core/Dialog/SavedataParam.cpp +++ b/Core/Dialog/SavedataParam.cpp @@ -1103,9 +1103,14 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param) 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; - saveName = it->name.substr(strlen(gameName.c_str())); PSPFileInfo info = pspFileSystem.GetFileInfo(fileDataPath); if (info.exists) { SetFileInfo(realCount, info, saveName); @@ -1473,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);