mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-01-26 17:54:46 +01:00
Support variable expansion for paths under Linux
branch 'default' changed RetroFE/Source/Database/Configuration.cpp
This commit is contained in:
parent
a8adc21361
commit
94526ea8a9
@ -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];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user