mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2025-06-07 17:55:55 +02:00
Allow empty path to be set in app::paths
and allow returning empty path in Steam_Apps::GetAppInstallDir()
This commit is contained in:
parent
a343b8ab3f
commit
cee5ce34cc
4 changed files with 22 additions and 9 deletions
|
@ -401,7 +401,7 @@ public:
|
||||||
|
|
||||||
//App Install paths
|
//App Install paths
|
||||||
void setAppInstallPath(AppId_t appID, const std::string &path);
|
void setAppInstallPath(AppId_t appID, const std::string &path);
|
||||||
std::string getAppInstallPath(AppId_t appID);
|
bool getAppInstallPath(AppId_t appID, std::string &path);
|
||||||
|
|
||||||
//mod stuff
|
//mod stuff
|
||||||
void addMod(PublishedFileId_t id, const std::string &title, const std::string &path);
|
void addMod(PublishedFileId_t id, const std::string &title, const std::string &path);
|
||||||
|
|
|
@ -328,9 +328,16 @@ void Settings::setAppInstallPath(AppId_t appID, const std::string &path)
|
||||||
app_paths[appID] = path;
|
app_paths[appID] = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Settings::getAppInstallPath(AppId_t appID)
|
bool Settings::getAppInstallPath(AppId_t appID, std::string &path)
|
||||||
{
|
{
|
||||||
return app_paths[appID];
|
auto app_path = app_paths.find(appID);
|
||||||
|
if (app_paths.end() != app_path)
|
||||||
|
{
|
||||||
|
path = app_path->second;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setLeaderboard(const std::string &leaderboard, enum ELeaderboardSortMethod sort_method, enum ELeaderboardDisplayType display_type)
|
void Settings::setLeaderboard(const std::string &leaderboard, enum ELeaderboardSortMethod sort_method, enum ELeaderboardDisplayType display_type)
|
||||||
|
|
|
@ -767,15 +767,18 @@ static void parse_app_paths(class Settings *settings_client, Settings *settings_
|
||||||
|
|
||||||
for (const auto &id : ids) {
|
for (const auto &id : ids) {
|
||||||
auto val_ptr = ini.GetValue("app::paths", id.pItem);
|
auto val_ptr = ini.GetValue("app::paths", id.pItem);
|
||||||
if (!val_ptr || !val_ptr[0]) continue;
|
// NOTE: empty path means we actively disable the path to the appid specified
|
||||||
|
if (!val_ptr) continue;
|
||||||
|
|
||||||
AppId_t appid = (AppId_t)std::stoul(id.pItem);
|
AppId_t appid = (AppId_t)std::stoul(id.pItem);
|
||||||
std::string rel_path(val_ptr);
|
std::string rel_path(val_ptr);
|
||||||
std::string path = canonical_path(program_path + rel_path);
|
std::string path{};
|
||||||
|
if (rel_path.size())
|
||||||
|
path = canonical_path(program_path + rel_path);
|
||||||
|
|
||||||
if (appid) {
|
if (appid) {
|
||||||
if (path.size()) {
|
if (!rel_path.size() || path.size()) {
|
||||||
PRINT_DEBUG("Adding app path: %u|%s|", appid, path.c_str());
|
PRINT_DEBUG("Adding app path: %u|%s|%s", appid, rel_path.c_str(), path.c_str());
|
||||||
settings_client->setAppInstallPath(appid, path);
|
settings_client->setAppInstallPath(appid, path);
|
||||||
settings_server->setAppInstallPath(appid, path);
|
settings_server->setAppInstallPath(appid, path);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -321,9 +321,9 @@ uint32 Steam_Apps::GetAppInstallDir( AppId_t appID, char *pchFolder, uint32 cchF
|
||||||
PRINT_DEBUG("%u %p %u", appID, pchFolder, cchFolderBufferSize);
|
PRINT_DEBUG("%u %p %u", appID, pchFolder, cchFolderBufferSize);
|
||||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||||
//TODO return real path instead of dll path
|
//TODO return real path instead of dll path
|
||||||
std::string installed_path = settings->getAppInstallPath(appID);
|
std::string installed_path;
|
||||||
|
|
||||||
if (installed_path.empty()) {
|
if (!settings->getAppInstallPath(appID, installed_path)) {
|
||||||
std::string dll_path = get_full_program_path();
|
std::string dll_path = get_full_program_path();
|
||||||
std::string current_path = get_current_path();
|
std::string current_path = get_current_path();
|
||||||
PRINT_DEBUG(" dll: '%s', current: '%s'", dll_path.c_str(), current_path.c_str());
|
PRINT_DEBUG(" dll: '%s', current: '%s'", dll_path.c_str(), current_path.c_str());
|
||||||
|
@ -335,6 +335,9 @@ uint32 Steam_Apps::GetAppInstallDir( AppId_t appID, char *pchFolder, uint32 cchF
|
||||||
installed_path = dll_path;
|
installed_path = dll_path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (installed_path.empty()) {
|
||||||
|
return 0; // NOTE: empty path means we actively disable the path to the appid specified
|
||||||
|
}
|
||||||
|
|
||||||
PRINT_DEBUG(" final path '%s'", installed_path.c_str());
|
PRINT_DEBUG(" final path '%s'", installed_path.c_str());
|
||||||
if (pchFolder && cchFolderBufferSize) {
|
if (pchFolder && cchFolderBufferSize) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue