MCPcopy Create free account
hub / github.com/Kitware/CMake / GetPath

Method GetPath

Source/kwsys/SystemTools.cxx:608–642  ·  view source on GitHub ↗

adds the elements of the env variable path to the arg passed in

Source from the content-addressed store, hash-verified

606
607// adds the elements of the env variable path to the arg passed in
608void SystemTools::GetPath(std::vector<std::string>& path, char const* env)
609{
610 size_t const old_size = path.size();
611#if defined(_WIN32) && !defined(__CYGWIN__)
612 char const pathSep = ';';
613#else
614 char const pathSep = ':';
615#endif
616 if (!env) {
617 env = "PATH";
618 }
619 std::string pathEnv;
620 if (!SystemTools::GetEnv(env, pathEnv)) {
621 return;
622 }
623
624 // A hack to make the below algorithm work.
625 if (!pathEnv.empty() && pathEnv.back() != pathSep) {
626 pathEnv += pathSep;
627 }
628 std::string::size_type start = 0;
629 bool done = false;
630 while (!done) {
631 std::string::size_type endpos = pathEnv.find(pathSep, start);
632 if (endpos != std::string::npos) {
633 path.push_back(pathEnv.substr(start, endpos - start));
634 start = endpos + 1;
635 } else {
636 done = true;
637 }
638 }
639 for (auto i = path.begin() + old_size; i != path.end(); ++i) {
640 SystemTools::ConvertToUnixSlashes(*i);
641 }
642}
643
644#if defined(_WIN32)
645char const* SystemToolsStatic::GetEnvBuffered(char const* key)

Callers 10

GetFilesMethod · 0.80
GetInstallObjectNamesMethod · 0.80
GetTargetObjectNamesMethod · 0.80
doLongPathTestFunction · 0.80

Calls 8

push_backMethod · 0.80
sizeMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45
findMethod · 0.45
substrMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 1

doLongPathTestFunction · 0.64