| 507 | ////////////////////////////////////////////////////////////////////////// |
| 508 | |
| 509 | std::string resolveRelativePath(const std::string& _path, const std::string& _relativeTo, const bool _allowHome) |
| 510 | { |
| 511 | const std::string path = getGenericPath(_path); |
| 512 | const std::string relativeTo = isDirectory(_relativeTo) ? getGenericPath(_relativeTo) : getParent(_relativeTo); |
| 513 | |
| 514 | // nothing to resolve |
| 515 | if(!path.length()) |
| 516 | return path; |
| 517 | |
| 518 | // replace '.' with relativeTo |
| 519 | if((path[0] == '.') && (path[1] == '/')) |
| 520 | return (relativeTo + &(path[1])); |
| 521 | |
| 522 | // replace '~' with homePath |
| 523 | if(_allowHome && (path[0] == '~') && (path[1] == '/')) |
| 524 | return (getHomePath() + &(path[1])); |
| 525 | |
| 526 | // nothing to resolve |
| 527 | return path; |
| 528 | |
| 529 | } // resolveRelativePath |
| 530 | |
| 531 | ////////////////////////////////////////////////////////////////////////// |
| 532 |
no test coverage detected