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

Method FindName

Source/kwsys/SystemTools.cxx:2882–2908  ·  view source on GitHub ↗

* Find the file the given name. Searches the given path and then * the system search path. Returns the full path to the file if it is * found. Otherwise, the empty string is returned. */

Source from the content-addressed store, hash-verified

2880 * found. Otherwise, the empty string is returned.
2881 */
2882std::string SystemToolsStatic::FindName(
2883 std::string const& name, std::vector<std::string> const& userPaths,
2884 bool no_system_path)
2885{
2886 // Add the system search path to our path first
2887 std::vector<std::string> path;
2888 if (!no_system_path) {
2889 SystemTools::GetPath(path, "CMAKE_FILE_PATH");
2890 SystemTools::GetPath(path);
2891 }
2892 // now add the additional paths
2893 path.reserve(path.size() + userPaths.size());
2894 path.insert(path.end(), userPaths.begin(), userPaths.end());
2895 // now look for the file
2896 for (std::string const& p : path) {
2897 std::string tryPath = p;
2898 if (tryPath.empty() || tryPath.back() != '/') {
2899 tryPath += '/';
2900 }
2901 tryPath += name;
2902 if (SystemTools::FileExists(tryPath)) {
2903 return tryPath;
2904 }
2905 }
2906 // Couldn't find the file.
2907 return "";
2908}
2909
2910/**
2911 * Find the file the given name. Searches the given path and then

Callers

nothing calls this directly

Calls 9

GetPathFunction · 0.85
reserveMethod · 0.80
FileExistsFunction · 0.50
sizeMethod · 0.45
insertMethod · 0.45
endMethod · 0.45
beginMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45

Tested by

no test coverage detected