Expand '~' as user homedir shortcut when adding data directories
This matches the behavior used when searching for specific input files.
This commit is contained in:
parent
4fe58661e1
commit
ca8700fdd4
1 changed files with 11 additions and 0 deletions
|
|
@ -379,6 +379,17 @@ void Application::addDataDirectory(const std::string& dir)
|
|||
}
|
||||
string d = stripnonprint(dir);
|
||||
|
||||
// Expand "~/" to user's home directory, if possible
|
||||
if (d.find("~/") == 0 || d.find("~\\") == 0) {
|
||||
char* home = getenv("HOME"); // POSIX systems
|
||||
if (!home) {
|
||||
home = getenv("USERPROFILE"); // Windows systems
|
||||
}
|
||||
if (home) {
|
||||
d = home + d.substr(1, npos);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove any existing entry for this directory
|
||||
auto iter = std::find(inputDirs.begin(), inputDirs.end(), d);
|
||||
if (iter != inputDirs.end()) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue