mirror of
https://github.com/libretro/ppsspp.git
synced 2024-12-04 23:16:41 +00:00
Add savestates to the list(with automatic rename)
This commit is contained in:
parent
737152f9ef
commit
12dc7163f6
@ -18,6 +18,7 @@
|
||||
#include "file/file_util.h"
|
||||
#include "util/text/utf8.h"
|
||||
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/StringUtils.h"
|
||||
#ifdef _WIN32
|
||||
#include "Common/CommonWindows.h"
|
||||
@ -333,5 +334,30 @@ bool Load_PSP_ELF_PBP(FileLoader *fileLoader, std::string *error_string) {
|
||||
INFO_LOG(LOADER, "%s", title);
|
||||
host->SetWindowTitle(title);
|
||||
|
||||
// Temporary code
|
||||
// TODO: Remove this after ~ 1.6
|
||||
// It checks for old filenames for homebrew savestates(folder name) and rename them to new fakeID format
|
||||
std::string savestateDir = GetSysDirectory(DIRECTORY_SAVESTATE);
|
||||
savestateDir = ReplaceAll(savestateDir, "\\", "/");
|
||||
#ifdef _WIN32
|
||||
// Turn the slashes back to the Windows way.
|
||||
savestateDir = ReplaceAll(savestateDir, "/", "\\");
|
||||
#endif
|
||||
for (int i = 0; i < 5; i += 1) {
|
||||
std::string oldName = StringFromFormat("%s%s_%i.ppst", savestateDir.c_str(), homebrewName.c_str(), i);
|
||||
if (File::Exists(oldName)) {
|
||||
std::string newName = StringFromFormat("%s%s_1.00_%i.ppst", savestateDir.c_str(), madeUpID.c_str(), i);
|
||||
File::Rename(oldName, newName);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 5; i += 1) {
|
||||
std::string oldName = StringFromFormat("%s%s_%i.jpg", savestateDir.c_str(), homebrewName.c_str(), i);
|
||||
if (File::Exists(oldName)) {
|
||||
std::string newName = StringFromFormat("%s%s_1.00_%i.jpg", savestateDir.c_str(), madeUpID.c_str(), i);
|
||||
File::Rename(oldName, newName);
|
||||
}
|
||||
}
|
||||
// End of temporary code
|
||||
|
||||
return __KernelLoadExec(finalName.c_str(), 0, error_string);
|
||||
}
|
||||
|
@ -363,31 +363,13 @@ namespace SaveState
|
||||
std::string GenerateSaveSlotFilename(const std::string &gameFilename, int slot, const char *extension)
|
||||
{
|
||||
std::string discId = g_paramSFO.GetValueString("DISC_ID");
|
||||
std::string discVer = g_paramSFO.GetValueString("DISC_VERSION");
|
||||
std::string fullDiscId;
|
||||
if (discId.size()) {
|
||||
fullDiscId = StringFromFormat("%s_%s",
|
||||
g_paramSFO.GetValueString("DISC_ID").c_str(),
|
||||
g_paramSFO.GetValueString("DISC_VERSION").c_str());
|
||||
} else {
|
||||
// Okay, no discId. Probably homebrew, let's use the last part of the path name.
|
||||
if (File::IsDirectory(gameFilename)) {
|
||||
// EBOOT.PBP directory, most likely.
|
||||
std::string path = gameFilename;
|
||||
size_t slash = path.rfind('/'); // Always '/', not '\\', as we're in a virtual directory
|
||||
if (slash != std::string::npos && slash < path.size() - 1)
|
||||
path = path.substr(slash + 1);
|
||||
fullDiscId = path;
|
||||
} else {
|
||||
// Probably a loose elf.
|
||||
std::string fn = File::GetFilename(gameFilename);
|
||||
size_t dot = fn.rfind('.');
|
||||
if (dot != std::string::npos) {
|
||||
fullDiscId = fn.substr(0, dot);
|
||||
} else {
|
||||
fullDiscId = "elf"; // Fallback
|
||||
}
|
||||
}
|
||||
if (discId.empty()) {
|
||||
discId = g_paramSFO.GenerateFakeID();
|
||||
discVer = "1.00";
|
||||
}
|
||||
fullDiscId = StringFromFormat("%s_%s", discId.c_str(), discVer.c_str());
|
||||
|
||||
std::string temp = StringFromFormat("ms0:/PSP/PPSSPP_STATE/%s_%i.%s", fullDiscId.c_str(), slot, extension);
|
||||
std::string hostPath;
|
||||
|
Loading…
Reference in New Issue
Block a user