| 282 | } |
| 283 | |
| 284 | void Application::addDataDirectory(const string& dir) |
| 285 | { |
| 286 | std::unique_lock<std::mutex> dirLock(dir_mutex); |
| 287 | if (inputDirs.empty()) { |
| 288 | setDefaultDirectories(); |
| 289 | } |
| 290 | string d = stripnonprint(dir); |
| 291 | |
| 292 | // Expand "~/" to user's home directory, if possible |
| 293 | if (d.find("~/") == 0 || d.find("~\\") == 0) { |
| 294 | char* home = getenv("HOME"); // POSIX systems |
| 295 | if (!home) { |
| 296 | home = getenv("USERPROFILE"); // Windows systems |
| 297 | } |
| 298 | if (home) { |
| 299 | d = home + d.substr(1, npos); |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | // Remove any existing entry for this directory |
| 304 | auto iter = std::find(inputDirs.begin(), inputDirs.end(), d); |
| 305 | if (iter != inputDirs.end()) { |
| 306 | inputDirs.erase(iter); |
| 307 | } |
| 308 | |
| 309 | // Insert this directory at the beginning of the search path |
| 310 | inputDirs.insert(inputDirs.begin(), d); |
| 311 | } |
| 312 | |
| 313 | string Application::findInputFile(const string& name) |
| 314 | { |
no test coverage detected