From f2b86cd5a025a067a7bd637e9abe373064ed8b20 Mon Sep 17 00:00:00 2001 From: Winos <42523848+Johnny-Connor@users.noreply.github.com> Date: Sun, 15 Dec 2024 16:58:56 -0300 Subject: [PATCH] Improved error handling as requested. --- src/Security/BeamNG.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Security/BeamNG.cpp b/src/Security/BeamNG.cpp index 0759e29..705c3c3 100644 --- a/src/Security/BeamNG.cpp +++ b/src/Security/BeamNG.cpp @@ -189,20 +189,30 @@ void LegitimacyCheck() { "snap/steam/common/.local/share/Steam/steamapps" // snap }; + std::filesystem::path steamappsPath; std::filesystem::path libraryFoldersPath; + bool steamappsFolderFound = false; bool libraryFoldersFound = false; for (const auto& path : steamappsCommonPaths) { - std::filesystem::path fullPath = homeDir / path / "libraryfolders.vdf"; - if (std::filesystem::exists(fullPath)) { - libraryFoldersPath = fullPath; - libraryFoldersFound = true; - break; + steamappsPath = homeDir / path; + if (std::filesystem::exists(steamappsPath)) { + steamappsFolderFound = true; + libraryFoldersPath = steamappsPath / "libraryfolders.vdf"; + if (std::filesystem::exists(libraryFoldersPath)) { + libraryFoldersPath = libraryFoldersPath; + libraryFoldersFound = true; + break; + } } } + if (!steamappsFolderFound) { + error("Unsupported Steam installation."); + return; + } if (!libraryFoldersFound) { - error("Did not find a valid path to a libraryfolders.vdf file."); + error("libraryfolders.vdf is missing."); return; }