Fix shortcuts.vdf must be present before adding one to steam

- Only create backup in case a file exists.
- Also, only create backup if no backup exists.
  If glossi nukes the vdf file, more than 1 add operation would also nuke the last backup
- Add log output to shortcut backup

Fixes: #163
pull/175/head
Peter Repukat 2 years ago
parent 614980144c
commit 349e411259

@ -51,8 +51,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,7,1
PRODUCTVERSION 0,0,7,1
FILEVERSION 0,0,7,102000153200
PRODUCTVERSION 0,0,7,102000153200
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -69,12 +69,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Peter Repukat - FlatspotSoftware"
VALUE "FileDescription", "GlosSI - Config"
VALUE "FileVersion", "0.0.7.1"
VALUE "FileVersion", "0.0.7.1-2-gd15320b"
VALUE "InternalName", "GlosSIConfig"
VALUE "LegalCopyright", "Copyright (C) 2021 Peter Repukat - FlatspotSoftware"
VALUE "OriginalFilename", "GlosSIConfig.exe"
VALUE "ProductName", "GlosSI"
VALUE "ProductVersion", "0.0.7.1"
VALUE "ProductVersion", "0.0.7.1-2-gd15320b"
END
END
BLOCK "VarFileInfo"
@ -108,3 +108,19 @@ IDI_ICON1 ICON "..\GloSC_Icon.ico"
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

@ -24,6 +24,8 @@ limitations under the License.
#include <string>
#include <vector>
#include <QDebug>
namespace VDFParser {
namespace crc {
template <typename CONT>
@ -489,7 +491,14 @@ class Parser {
static inline bool writeShortcuts(std::filesystem::path path, const VDFFile& vdffile)
{
const auto copied = std::filesystem::copy_file(path, path.wstring() + L".bak", std::filesystem::copy_options::update_existing);
const auto backupFileName = path.wstring() + L".bak";
if (std::filesystem::exists(path) && !std::filesystem::exists(backupFileName)) {
qDebug() << "No shortcuts backup detected... Creating now...";
const auto copied = std::filesystem::copy_file(path, backupFileName, std::filesystem::copy_options::update_existing);
if (!copied) {
qDebug() << "failed to copy shortcuts.vdf to backup!";
}
}
ofile.open(path.wstring(), std::ios::binary | std::ios::out);
if (!ofile.is_open()) {

Loading…
Cancel
Save