static void addGmshPathToEnvironmentVar(const std::string &name) { std::vector<std::string> split = SplitFileName(CTX::instance()->argv0); std::string path; char *tmp = getenv(name.c_str()); if(tmp){ path = tmp; #if defined(WIN32) path += ";" + split[0]; #else path += ":" + split[0]; #endif } else path = split[0]; SetEnvironmentVar(name.c_str(), path.c_str()); }
bool PrependPathToEnvironmentVar(const char *variableName, const char *path) { std::string oldValue = GetEnvironmentVar(variableName); const char *newValue = nullptr; std::string buf; if (oldValue.empty()) { newValue = path; } else { buf = path; buf += GetPathSeparator(); buf += oldValue; newValue = buf.c_str(); } return SetEnvironmentVar(variableName, newValue); }