RemoveGameConfig improved

This commit is contained in:
Nekotekina 2017-03-27 15:12:34 +03:00
parent 66835cf083
commit 4c789faea4

View File

@ -253,15 +253,26 @@ void GameViewer::RemoveGameConfig(wxCommandEvent& event)
long i = GetFirstSelected();
if (i < 0) return;
if (fs::exists(fs::get_config_dir() + "data/" + m_game_data[i].serial + "/config.yml"))
const std::string config_path = fs::get_config_dir() + "data/" + m_game_data[i].serial + "/config.yml";
if (fs::is_file(config_path))
{
if (wxMessageBox("Delete custom game configuration?", "Confirm Delete", wxYES_NO | wxNO_DEFAULT) == wxYES)
{
fs::remove_file(fs::get_config_dir() + "data/" + m_game_data[i].serial + "/config.yml");
if (fs::remove_file(config_path))
{
LOG_SUCCESS(GENERAL, "Removed configuration file: %s", config_path);
}
else
{
LOG_FATAL(GENERAL, "Failed to delete configuration file: %s\nError: %s", config_path, fs::g_tls_error);
}
}
}
Refresh();
else
{
LOG_ERROR(GENERAL, "Configuration file not found: %s", config_path);
}
}
static void open_dir(const std::string& spath)