Commit 30df25df2ef8c8aefdef65636ce798b45616a4d4

Authored by Jürgen Knödlseder
1 parent 6022837c

Check of parameter file exists in sysfiles folder before loading it.

This makes sure that the code also work in absence of the parameter file or a sysfiles folder.
Showing 1 changed file with 9 additions and 5 deletions
src/support/ctool.cpp
... ... @@ -258,13 +258,17 @@ void ctool::init_members(void)
258 258 // Set language to english to make sure that a dot is a dot
259 259 std::setlocale(LC_ALL, "en_US.UTF-8");
260 260  
261   - // Set parameter syspfiles and reload parameter file
  261 + // If CTOOLS environment variable is set and if a parameter exists in
  262 + // the syspfiles folder then set syspfiles folder and reload parameter file
262 263 char* ptr = std::getenv("CTOOLS");
263 264 if (ptr != NULL) {
264   - std::string path = std::string(ptr) + "/syspfiles";
265   - m_pars.clear();
266   - m_pars.syspfiles(path);
267   - m_pars.load(par_filename());
  265 + std::string path = std::string(ptr) + "/syspfiles";
  266 + std::string filename = path + "/" + par_filename();
  267 + if (access(filename.c_str(), R_OK) == 0) {
  268 + m_pars.clear();
  269 + m_pars.syspfiles(path);
  270 + m_pars.load(par_filename());
  271 + }
268 272 }
269 273  
270 274 // Return
... ...