Commit 8650677b4fb0ecb7cd96ce68a67b990b1aa133fb
1 parent
35fceede
Expand environment variable before checking the existence of the directory.
Showing
1 changed file
with
8 additions
and
6 deletions
src/obs/GCaldb.cpp
| ... | ... | @@ -318,20 +318,22 @@ std::string GCaldb::rootdir(void) const |
| 318 | 318 | ***************************************************************************/ |
| 319 | 319 | void GCaldb::rootdir(const std::string& pathname) |
| 320 | 320 | { |
| 321 | + // Expand pathname | |
| 322 | + std::string rootdir = gammalib::expand_env(pathname); | |
| 323 | + | |
| 321 | 324 | // Verify that specified root directory exists |
| 322 | - //if (access(pathname.c_str(), F_OK) != 0) { | |
| 323 | - if (!gammalib::dir_exists(pathname)) { | |
| 324 | - throw GException::directory_not_found(G_SET_ROOTDIR, pathname); | |
| 325 | + if (!gammalib::dir_exists(rootdir)) { | |
| 326 | + throw GException::directory_not_found(G_SET_ROOTDIR, rootdir); | |
| 325 | 327 | } |
| 326 | 328 | |
| 327 | 329 | // Verify that specified root directory allows read access |
| 328 | - if (access(pathname.c_str(), R_OK) != 0) { | |
| 329 | - throw GException::directory_not_accessible(G_SET_ROOTDIR, pathname, | |
| 330 | + if (access(rootdir.c_str(), R_OK) != 0) { | |
| 331 | + throw GException::directory_not_accessible(G_SET_ROOTDIR, rootdir, | |
| 330 | 332 | "Requested read permission not granted."); |
| 331 | 333 | } |
| 332 | 334 | |
| 333 | 335 | // Set calibration database root directory |
| 334 | - m_opt_rootdir = gammalib::expand_env(pathname); | |
| 336 | + m_opt_rootdir = rootdir; | |
| 335 | 337 | |
| 336 | 338 | // Return |
| 337 | 339 | return; | ... | ... |