Skip to content

Commit

Permalink
[Base] Move CANTERA_DATA environment variable up in search path
Browse files Browse the repository at this point in the history
The paths added from the CANTERA_DATA environment variable should be searched
before hard-coded paths which are determined based on the installation location.
  • Loading branch information
speth committed Jul 29, 2016
1 parent f733fac commit dac5345
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions src/base/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,28 @@ void Application::setDefaultDirectories()
// always look in the local directory first
inputDirs.push_back(".");

// if environment variable CANTERA_DATA is defined, then add it to the
// search path. CANTERA_DATA may include multiple directory, separated by
// the OS-dependent path separator (in the same manner as the PATH
// environment variable).
#ifdef _WIN32
std::string pathsep = ";";
#else
std::string pathsep = ":";
#endif

if (getenv("CANTERA_DATA") != 0) {
string s = string(getenv("CANTERA_DATA"));
size_t start = 0;
size_t end = s.find(pathsep);
while(end != npos) {
inputDirs.push_back(s.substr(start, end-start));
start = end + 1;
end = s.find(pathsep, start);
}
inputDirs.push_back(s.substr(start,end));
}

#ifdef _WIN32
// Under Windows, the Cantera setup utility records the installation
// directory in the registry. Data files are stored in the 'data'
Expand Down Expand Up @@ -353,28 +375,6 @@ void Application::setDefaultDirectories()
inputDirs.push_back("/Applications/Cantera/data");
#endif

// if environment variable CANTERA_DATA is defined, then add it to the
// search path. CANTERA_DATA may include multiple directory, separated by
// the OS-dependent path separator (in the same manner as the PATH
// environment variable).
#ifdef _WIN32
std::string pathsep = ";";
#else
std::string pathsep = ":";
#endif

if (getenv("CANTERA_DATA") != 0) {
string s = string(getenv("CANTERA_DATA"));
size_t start = 0;
size_t end = s.find(pathsep);
while(end != npos) {
inputDirs.push_back(s.substr(start, end-start));
start = end + 1;
end = s.find(pathsep, start);
}
inputDirs.push_back(s.substr(start,end));
}

// CANTERA_DATA is defined in file config.h. This file is written during the
// build process (unix), and points to the directory specified by the
// 'prefix' option to 'configure', or else to /usr/local/cantera.
Expand Down

0 comments on commit dac5345

Please sign in to comment.