mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
Savestate browser: delete the screenshot and name file along with the state
Deleting a savestate from the savedata screen goes through GameInfo::Delete, not SaveState::DeleteSlot, and it only knew about the .jpg - so the slot's .name.txt was left behind with nothing to belong to. Rather than teach the UI the naming scheme a third time, SaveState now answers what sits beside a state. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
1 parent
55f53d4523
commit
6600d1c05f
3 files changed
+26
-3
No files matched your search
@@ -735,6 +735,21 @@ int g_screenshotFailures;
|
|||||||
Rescan(gamePrefix);
|
Rescan(gamePrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Path> GetCompanionFilePaths(const Path &statePath) {
|
||||||
|
const std::string stateExtension = std::string(".") + STATE_EXTENSION;
|
||||||
|
// A path that isn't a savestate yields nothing, which WithReplacedExtension now tells us
|
||||||
|
// rather than handing back the path itself. An undo state does work, and correctly:
|
||||||
|
// "x.undo.ppst" maps onto "x.undo.jpg".
|
||||||
|
std::vector<Path> paths;
|
||||||
|
for (const char *extension : { SCREENSHOT_EXTENSION, NAME_EXTENSION }) {
|
||||||
|
Path companion;
|
||||||
|
if (statePath.WithReplacedExtension(stateExtension, std::string(".") + extension, &companion)) {
|
||||||
|
paths.push_back(companion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return paths;
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<Operation> Flush() {
|
std::vector<Operation> Flush() {
|
||||||
std::lock_guard<std::mutex> guard(mutex);
|
std::lock_guard<std::mutex> guard(mutex);
|
||||||
std::vector<Operation> copy = g_pendingOperations;
|
std::vector<Operation> copy = g_pendingOperations;
|
||||||
|
|||||||
@@ -79,6 +79,12 @@ namespace SaveState {
|
|||||||
Path GenerateSaveSlotPath(std::string_view gamePrefix, int slot, const char *extension);
|
Path GenerateSaveSlotPath(std::string_view gamePrefix, int slot, const char *extension);
|
||||||
void SetSlotCustomName(std::string_view gamePrefix, int slot, std::string_view newName);
|
void SetSlotCustomName(std::string_view gamePrefix, int slot, std::string_view newName);
|
||||||
|
|
||||||
|
// The files that sit beside a savestate and mean nothing without it: its screenshot, and the
|
||||||
|
// slot's custom name if it was given one. Anything deleting a .ppst from outside DeleteSlot -
|
||||||
|
// the savestate browser does exactly that - has to take these along, or they stay in the
|
||||||
|
// savestate folder for good. Returns nothing for a path that isn't a savestate.
|
||||||
|
std::vector<Path> GetCompanionFilePaths(const Path &statePath);
|
||||||
|
|
||||||
std::string GetTitle(const Path &filename);
|
std::string GetTitle(const Path &filename);
|
||||||
|
|
||||||
// Load the specified file into the current state (async.)
|
// Load the specified file into the current state (async.)
|
||||||
|
|||||||
@@ -170,9 +170,11 @@ bool GameInfo::Delete() {
|
|||||||
const Path &ppstPath = filePath_;
|
const Path &ppstPath = filePath_;
|
||||||
INFO_LOG(Log::System, "Deleting file %s", ppstPath.c_str());
|
INFO_LOG(Log::System, "Deleting file %s", ppstPath.c_str());
|
||||||
MoveFileToTrashOrDelete(ppstPath);
|
MoveFileToTrashOrDelete(ppstPath);
|
||||||
Path screenshotPath;
|
// The screenshot and the slot's custom name are no use without the state itself.
|
||||||
if (filePath_.WithReplacedExtension(".ppst", ".jpg", &screenshotPath) && File::Exists(screenshotPath)) {
|
for (const Path &companion : SaveState::GetCompanionFilePaths(ppstPath)) {
|
||||||
MoveFileToTrashOrDelete(screenshotPath);
|
if (File::Exists(companion)) {
|
||||||
|
MoveFileToTrashOrDelete(companion);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user