From 6b6d86c035094932a7542d7a6b839e03705415a3 Mon Sep 17 00:00:00 2001 From: Fournet Enzo Date: Wed, 27 Nov 2024 13:21:58 +0100 Subject: [PATCH] string to char --- src/Security/BeamNG.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Security/BeamNG.cpp b/src/Security/BeamNG.cpp index 659aac8..66e05b3 100644 --- a/src/Security/BeamNG.cpp +++ b/src/Security/BeamNG.cpp @@ -182,20 +182,20 @@ std::string GetBottleName() { return bottlePath.filename().string(); } -std::map GetDriveMappings(const std::string& bottlePath) { - std::map driveMappings; +std::map GetDriveMappings(const std::string& bottlePath) { + std::map driveMappings; std::string dosDevicesPath = bottlePath + "/dosdevices/"; if (std::filesystem::exists(dosDevicesPath)) { for (const auto& entry : std::filesystem::directory_iterator(dosDevicesPath)) { if (entry.is_symlink()) { std::string driveName = Utils::ToLower(entry.path().filename().string()); - driveName = driveName.substr(0, 1); + char driveLetter = driveName[0]; std::string macPath = std::filesystem::read_symlink(entry.path()).string(); if (!std::filesystem::path(macPath).is_absolute()) { macPath = dosDevicesPath + macPath; } - driveMappings[driveName] = macPath; + driveMappings[driveLetter] = macPath; } } } else { @@ -204,20 +204,18 @@ std::map GetDriveMappings(const std::string& bottlePat return driveMappings; } -bool CheckForGame(const std::string& libraryPath, const std::map& driveMappings) { +bool CheckForGame(const std::string& libraryPath, const std::map& driveMappings) { //Convert the Windows path to Unix path - char driveLetterChar = std::tolower(libraryPath[0]); - std::string driveLetter(1, driveLetterChar); + char driveLetter = std::tolower(libraryPath[0]); if (!driveMappings.contains(driveLetter)) { - warn("Drive letter " + driveLetter + " not found in mappings."); + warn(std::string("Drive letter ") + driveLetter + " not found in mappings."); return false; } std::filesystem::path basePath = driveMappings.at(driveLetter); debug("Base path: " + basePath.string()); - std::filesystem::path cleanLibraryPath = std::filesystem::path(libraryPath.substr(2)).make_preferred(); std::string cleanPathStr = cleanLibraryPath.string(); std::replace(cleanPathStr.begin(), cleanPathStr.end(), '\\', '/');