Support variable expansion for paths under Linux

branch 'default'
changed RetroFE/Source/Database/Configuration.cpp
This commit is contained in:
xenonk 2015-03-22 06:39:20 -04:00
parent a8adc21361
commit 94526ea8a9

View File

@ -26,6 +26,7 @@
#else
#include <sys/types.h>
#include <unistd.h>
#include <wordexp.h>
#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];