From b8aa74af0ede3f305bb3ee914e97bfa7b7842851 Mon Sep 17 00:00:00 2001 From: Mr_Goldberg Date: Thu, 12 Dec 2019 14:11:05 -0500 Subject: [PATCH] GetAppInstallDir accuracy improvements. --- dll/steam_apps.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dll/steam_apps.cpp b/dll/steam_apps.cpp index f9f35f67..9bd382ac 100644 --- a/dll/steam_apps.cpp +++ b/dll/steam_apps.cpp @@ -213,9 +213,8 @@ uint32 Steam_Apps::GetInstalledDepots( AppId_t appID, DepotId_t *pvecDepots, uin // returns current app install folder for AppID, returns folder name length uint32 Steam_Apps::GetAppInstallDir( AppId_t appID, char *pchFolder, uint32 cchFolderBufferSize ) { - PRINT_DEBUG("GetAppInstallDir %u %u\n", appID, cchFolderBufferSize); + PRINT_DEBUG("GetAppInstallDir %u %p %u\n", appID, pchFolder, cchFolderBufferSize); //TODO return real path instead of dll path - if (!pchFolder || !cchFolderBufferSize) return 0; std::string installed_path = settings->getAppInstallPath(appID); if (installed_path.size() == 0) { @@ -232,8 +231,11 @@ uint32 Steam_Apps::GetAppInstallDir( AppId_t appID, char *pchFolder, uint32 cchF } PRINT_DEBUG("path %s\n", installed_path.c_str()); - snprintf(pchFolder, cchFolderBufferSize, "%s", installed_path.c_str()); - return strlen(pchFolder); + if (cchFolderBufferSize && pchFolder) { + snprintf(pchFolder, cchFolderBufferSize, "%s", installed_path.c_str()); + } + + return installed_path.length(); //Real steam always returns the actual path length, not the copied one. } // returns true if that app is installed (not necessarily owned)