Allow CANTERA_DATA to include multiple directories

This commit is contained in:
Ray Speth 2014-12-12 01:36:56 +00:00
parent 693d5caaf6
commit ddfc15bb77
4 changed files with 32 additions and 15 deletions

View file

@ -302,10 +302,11 @@ Files\\Cantera\\data`` on Windows or ``/usr/local/cantera/data/`` on
Unix/Linux/Mac OS X machines, depending on how you installed Cantera and the
options you specified.
If for some reason Cantera has difficulty finding where these files are on
your system, set environment variable ``CANTERA_DATA`` to the directory where
they are located. Alternatively, you can call function `add_directory` to add
a directory to the Cantera search path::
If for some reason Cantera has difficulty finding where these files are on your
system, set environment variable ``CANTERA_DATA`` to the directory or
directories (separated using ``;`` on Windows or ``:`` on other operating
systems) where they are located. Alternatively, you can call function
`add_directory` to add a directory to the Cantera search path::
>>> ct.add_directory('/usr/local/cantera/my_data_files')

View file

@ -31,9 +31,10 @@ reaction mechanism, and a few surface reaction mechanisms. These files are kept
in the ``data`` subdirectory within the Cantera installation directory.
If for some reason Cantera has difficulty finding where these files are on your
system, set environment variable ``CANTERA_DATA`` to the directory where they
are located. Alternatively, you can call function ``addDirectory`` to add a
directory to the Cantera search path::
system, set environment variable ``CANTERA_DATA`` to the directory or
directories (separated using ``;`` on Windows or ``:`` on other operating
systems) where they are located. Alternatively, you can call function
`add_directory` to add a directory to the Cantera search path::
addDirectory('/usr/local/cantera/my_data_files');

View file

@ -75,8 +75,10 @@ void popError();
* On the Mac, directory '/Applications/Cantera/data' is added to the
* search path.
*
* On any platform, if environment variable CANTERA_DATA is set to a
* directory name, then this directory is added to the search path.
* On any platform, if environment variable CANTERA_DATA is set to a directory
* name or a list of directory names separated with the OS-dependent path
* separator (i.e. ";" on Windows, ":" elsewhere), then these directories will
* be added to the search path.
*
* Finally, the location where the data files were installed when
* %Cantera was built is added to the search path.

View file

@ -446,13 +446,26 @@ void Application::setDefaultDirectories()
dirs.push_back("/Applications/Cantera/data");
#endif
//
// if environment variable CANTERA_DATA is defined, then add
// it to the search path
//
// 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 datadir = string(getenv("CANTERA_DATA"));
dirs.push_back(datadir);
string s = string(getenv("CANTERA_DATA"));
size_t start = 0;
size_t end = s.find(pathsep);
while(end != npos) {
dirs.push_back(s.substr(start, end-start));
start = end + 1;
end = s.find(pathsep, start);
}
dirs.push_back(s.substr(start,end));
}
// CANTERA_DATA is defined in file config.h. This file is written