Safeguard GameManager::Uninstall from calls with empty filename.

Could wipe all your games if a bug would cause this to happen.
This commit is contained in:
Henrik Rydgard 2013-11-20 19:48:44 +01:00 committed by Henrik Rydgård
parent 15f45806b9
commit 3a6941c1ab
2 changed files with 9 additions and 3 deletions

View file

@ -56,20 +56,26 @@ bool GameManager::DownloadAndInstall(std::string storeZipUrl) {
return true;
}
void GameManager::Uninstall(std::string name) {
bool GameManager::Uninstall(std::string name) {
if (name.empty()) {
ERROR_LOG(HLE, "Cannot remove an empty-named game");
return false;
}
std::string gameDir = GetSysDirectory(DIRECTORY_GAME) + name;
INFO_LOG(HLE, "Deleting %s", gameDir.c_str());
if (!File::Exists(gameDir)) {
ERROR_LOG(HLE, "Game %s not installed, cannot uninstall", name.c_str());
return;
return false;
}
bool success = File::DeleteDirRecursively(gameDir);
if (success) {
INFO_LOG(HLE, "Successfully deleted game %s", name.c_str());
g_Config.CleanRecent();
return true;
} else {
ERROR_LOG(HLE, "Failed to delete game %s", name.c_str());
return false;
}
}

View file

@ -28,7 +28,7 @@ public:
// This starts off a background process.
bool DownloadAndInstall(std::string storeZipUrl);
void Uninstall(std::string name);
bool Uninstall(std::string name);
// Call from time to time to check on completed downloads from the
// main UI thread.