void Application::setDefaultDirectories() { std::vector<string>& dirs = inputDirs; // always look in the local directory first dirs.push_back("."); #ifdef _WIN32 // Under Windows, the Cantera setup utility records the installation // directory in the registry. Data files are stored in the 'data' and // 'templates' subdirectories of the main installation directory. std::string installDir; readStringRegistryKey("SOFTWARE\\Cantera\\Cantera 2.0", "InstallDir", installDir, ""); if (installDir != "") { dirs.push_back(installDir + "data"); dirs.push_back(installDir + "templates"); // Scripts for converting mechanisms to CTI and CMTL are installed in // the 'bin' subdirectory. Add that directory to the PYTHONPATH. const char* old_pythonpath = getenv("PYTHONPATH"); std::string pythonpath = "PYTHONPATH=" + installDir + "\\bin"; if (old_pythonpath) { pythonpath += ";"; pythonpath.append(old_pythonpath); } putenv(pythonpath.c_str()); } #endif #ifdef DARWIN // // add a default data location for Mac OS X // dirs.push_back("/Applications/Cantera/data"); #endif // // if environment variable CANTERA_DATA is defined, then add // it to the search path // if (getenv("CANTERA_DATA") != 0) { string datadir = string(getenv("CANTERA_DATA")); dirs.push_back(datadir); } // 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. #ifdef CANTERA_DATA string datadir = string(CANTERA_DATA); dirs.push_back(datadir); #endif }
void Application::setDefaultDirectories() { std::vector<string>& dirs = inputDirs; // always look in the local directory first dirs.push_back("."); #ifdef _WIN32 // Under Windows, the Cantera setup utility records the installation // directory in the registry. Data files are stored in the 'data' // subdirectory of the main installation directory. std::string installDir; readStringRegistryKey("SOFTWARE\\Cantera\\Cantera " CANTERA_SHORT_VERSION, "InstallDir", installDir, ""); if (installDir != "") { dirs.push_back(installDir + "data"); // Scripts for converting mechanisms to CTI and CMTL are installed in // the 'bin' subdirectory. Add that directory to the PYTHONPATH. const char* old_pythonpath = getenv("PYTHONPATH"); std::string pythonpath = "PYTHONPATH=" + installDir + "\\bin"; if (old_pythonpath) { pythonpath += ";"; pythonpath.append(old_pythonpath); } putenv(pythonpath.c_str()); } #endif #ifdef DARWIN // add a default data location for Mac OS X dirs.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) { 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 // during the build process (unix), and points to the directory // specified by the 'prefix' option to 'configure', or else to // /usr/local/cantera. #ifdef CANTERA_DATA string datadir = string(CANTERA_DATA); dirs.push_back(datadir); #endif }