MCPcopy Create free account
hub / github.com/MayaPosch/NymphCast / resolveRelativePath

Function resolveRelativePath

src/server/gui/core/utils/FileSystemUtil.cpp:509–529  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 5

parseIncludesMethod · 0.85
parseElementMethod · 0.85
parseGamelistFunction · 0.85
updateGamelistFunction · 0.85
createFromXMLMethod · 0.85

Calls 5

getGenericPathFunction · 0.85
isDirectoryFunction · 0.85
getParentFunction · 0.85
getHomePathFunction · 0.85
lengthMethod · 0.80

Tested by

no test coverage detected