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) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5 committed 2026-09-12 13:58:20 -06:00
1 parent 55f53d4523
commit 6600d1c05f
3 files changed
+26 -3

No files matched your search

+15
View File
@@ -735,6 +735,21 @@ int g_screenshotFailures;
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::lock_guard<std::mutex> guard(mutex);
std::vector<Operation> copy = g_pendingOperations;