From 94526ea8a9e3eb3e347884ffeb2f6c899b6133a8 Mon Sep 17 00:00:00 2001 From: xenonk Date: Sun, 22 Mar 2015 06:39:20 -0400 Subject: [PATCH] Support variable expansion for paths under Linux branch 'default' changed RetroFE/Source/Database/Configuration.cpp --- RetroFE/Source/Database/Configuration.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/RetroFE/Source/Database/Configuration.cpp b/RetroFE/Source/Database/Configuration.cpp index 538e098..320368b 100644 --- a/RetroFE/Source/Database/Configuration.cpp +++ b/RetroFE/Source/Database/Configuration.cpp @@ -26,6 +26,7 @@ #else #include #include +#include #endif std::string Configuration::AbsolutePath; @@ -306,6 +307,18 @@ std::string Configuration::ConvertToAbsolutePath(std::string prefix, std::string char first = ' '; char second = ' '; + // expand path variables +#ifdef WIN32 + // Do something equivalent to the 'nix code using Windows' ExpandEnvironmentStrings() here +#else + wordexp_t expandedPath; + wordexp(path.c_str(), &expandedPath, 0); + path = "\"" + path + "\""; + path.assign(expandedPath.we_wordv[0]); + path.erase(std::remove(path.begin(), path.end(), '"'), path.end()); + wordfree(&expandedPath); +#endif + if(path.length() >= 0) { first = path.c_str()[0];