Allow '~/' as alias for user's home directory when importing cti/xml

This commit is contained in:
Ray Speth 2014-07-10 22:33:20 +00:00
parent d5870c4e4b
commit 19e3a09980
2 changed files with 12 additions and 0 deletions

View file

@ -2612,6 +2612,7 @@ validate()
def convert(filename, outName=None):
import os
filename = os.path.expanduser(filename)
base = os.path.basename(filename)
root, _ = os.path.splitext(base)
dataset(root)

View file

@ -508,6 +508,17 @@ std::string Application::findInputFile(const std::string& name)
string inname;
std::vector<string>& dirs = inputDirs;
// Expand "~/" to user's home directory, if possible
if (name.find("~/") == 0) {
char* home = getenv("HOME"); // POSIX systems
if (!home) {
home = getenv("USERPROFILE"); // Windows systems
}
if (home) {
return home + name.substr(1, npos);
}
}
if (islash == string::npos && ibslash == string::npos) {
size_t nd = dirs.size();
inname = "";