diff --git a/GlosSIConfig/UIModel.cpp b/GlosSIConfig/UIModel.cpp index e440e54..bf4b6ed 100644 --- a/GlosSIConfig/UIModel.cpp +++ b/GlosSIConfig/UIModel.cpp @@ -268,7 +268,13 @@ bool UIModel::writeShortcutsVDF(const std::wstring& mode, const std::wstring& na qDebug() << "Steam config Path: " << config_path; qDebug() << "Trying to write config as admin: " << is_admin_try; - auto write_res = VDFParser::Parser::writeShortcuts(config_path, shortcuts_vdf_); + bool write_res; + try { + write_res = VDFParser::Parser::writeShortcuts(config_path, shortcuts_vdf_); + } + catch (const std::exception& e) { + qDebug() << "Couldn't backup shortcuts file: " << e.what(); + } if (!write_res && !is_admin_try) { wchar_t szPath[MAX_PATH]; diff --git a/GlosSIConfig/VDFParser.h b/GlosSIConfig/VDFParser.h index 0df48be..5dc8d23 100644 --- a/GlosSIConfig/VDFParser.h +++ b/GlosSIConfig/VDFParser.h @@ -271,8 +271,6 @@ struct VDFFile { //{ // std::wstring res = L"["; - - // res += L"]"; // return res; //} @@ -474,6 +472,8 @@ class Parser { static inline bool writeShortcuts(std::filesystem::path path, const VDFFile& vdffile) { + const auto copied = std::filesystem::copy_file(path, path.string() + ".bak", std::filesystem::copy_options::update_existing); + ofile.open(path.string(), std::ios::binary | std::ios::out); if (!ofile.is_open()) { return false;