Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/ps/SavedGame.cpp
/* Copyright (C) 2020 Wildfire Games. | /* Copyright (C) 2021 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 269 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
bool SavedGames::DeleteSavedGame(const std::wstring& name) | bool SavedGames::DeleteSavedGame(const std::wstring& name) | ||||
{ | { | ||||
const VfsPath basename(L"saves/" + name); | const VfsPath basename(L"saves/" + name); | ||||
const VfsPath filename = basename.ChangeExtension(L".0adsave"); | const VfsPath filename = basename.ChangeExtension(L".0adsave"); | ||||
OsPath realpath; | OsPath realpath; | ||||
// Make sure it exists in VFS and find its real path | // Make sure it exists in VFS and find its path | ||||
if (!VfsFileExists(filename) || g_VFS->GetRealPath(filename, realpath) != INFO::OK) | if (!VfsFileExists(filename) || g_VFS->GetOriginalPath(filename, realpath) != INFO::OK) | ||||
return false; // Error | return false; // Error | ||||
// Remove from VFS | // Remove from VFS | ||||
if (g_VFS->RemoveFile(filename) != INFO::OK) | if (g_VFS->RemoveFile(filename) != INFO::OK) | ||||
return false; // Error | return false; // Error | ||||
// Delete actual file | // Delete actual file | ||||
if (wunlink(realpath) != 0) | if (wunlink(realpath) != 0) | ||||
return false; // Error | return false; // Error | ||||
// Successfully deleted file | // Successfully deleted file | ||||
return true; | return true; | ||||
} | } |
Wildfire Games · Phabricator