| 29 |  | * @version 1.0 | 
| 30 |  | */ | 
| 31 |  |  | 
| 32 | + | #include <iostream> | 
| 33 |  | #include "config.h" | 
| 34 | + | #include <cstdlib> | 
| 35 |  | #include <string> | 
| 36 |  | #include <fstream> | 
| 37 | + | #include <cstdlib> | 
| 38 |  | #include "utils/ElementsTable.hpp" | 
| 39 |  | #include "utils/simError.h" | 
| 40 |  | #include "io/basic_ifstrstream.hpp" | 
| 78 |  | RealType red, green, blue; | 
| 79 |  |  | 
| 80 |  | // skip comment line (at the top) | 
| 78 | – |  | 
| 81 |  | if (line[0] != '#')  { | 
| 82 |  | sscanf(line,"%d %5s %lf %*f %lf %d %lf %lf %lf %lf %lf %lf %lf %255s", | 
| 83 |  | &num, | 
| 98 |  | elNeg, ionize, elAffin, red, green, blue, | 
| 99 |  | name); | 
| 100 |  | elements_.push_back(ele); | 
| 101 | + |  | 
| 102 |  | } | 
| 103 |  | } | 
| 104 |  |  | 
| 294 |  | buffer = getenv(envvar_.c_str()); | 
| 295 |  | buffer += FILE_SEP_CHAR; | 
| 296 |  |  | 
| 297 | + |  | 
| 298 | + |  | 
| 299 | + |  | 
| 300 |  | if (!subdir_.empty()) { | 
| 301 |  | subbuffer = buffer; | 
| 302 |  | subbuffer += subdir_; | 
| 303 |  | subbuffer += FILE_SEP_CHAR; | 
| 304 |  | } | 
| 305 |  |  | 
| 306 | + |  | 
| 307 | + |  | 
| 308 |  | buffer += filename_; | 
| 309 |  | subbuffer += filename_; | 
| 310 | + |  | 
| 311 |  |  | 
| 312 |  | ifs1.open(subbuffer.c_str()); | 
| 313 |  | ifsP= &ifs1; | 
| 314 | < | if (!(*ifsP)) { | 
| 314 | > | if (!(ifsP->is_open())) { | 
| 315 |  | ifs2.open(buffer.c_str()); | 
| 316 |  | ifsP = &ifs2; | 
| 317 |  | } | 
| 318 | + |  | 
| 319 |  | } else { | 
| 320 |  | sprintf( painCave.errMsg, | 
| 321 |  | "ElementsTable error.\n" | 
| 328 |  | if ((*ifsP)) { | 
| 329 |  | while(ifsP->getline(charBuffer,BUFF_SIZE)) | 
| 330 |  | ParseLine(charBuffer); | 
| 331 | < |  | 
| 332 | < | if (ifs1) | 
| 333 | < | ifs1.close(); | 
| 334 | < | if (ifs2) | 
| 335 | < | ifs2.close(); | 
| 336 | < | if (ifs3) | 
| 337 | < | ifs3.close(); | 
| 338 | < | if (ifs4) | 
| 339 | < | ifs4.close(); | 
| 340 | < |  | 
| 341 | < | if (GetSize() == 0) { | 
| 342 | < | sprintf( painCave.errMsg, | 
| 343 | < | "ElementsTable error.\n" | 
| 344 | < | "\tCannot initialize database %s \n", filename_.c_str()); | 
| 345 | < | painCave.isFatal = 0; | 
| 346 | < | simError(); | 
| 347 | < | } | 
| 331 | > |  | 
| 332 | > | if (ifs1) | 
| 333 | > | ifs1.close(); | 
| 334 | > | if (ifs2) | 
| 335 | > | ifs2.close(); | 
| 336 | > | if (ifs3) | 
| 337 | > | ifs3.close(); | 
| 338 | > | if (ifs4) | 
| 339 | > | ifs4.close(); | 
| 340 | > |  | 
| 341 | > | if (GetSize() == 0) { | 
| 342 | > | sprintf( painCave.errMsg, | 
| 343 | > | "ElementsTable error.\n" | 
| 344 | > | "\tCannot initialize database %s \n", filename_.c_str()); | 
| 345 | > | painCave.isFatal = 0; | 
| 346 | > | simError(); | 
| 347 | > | } | 
| 348 |  |  | 
| 349 |  | } | 
| 350 |  |  |