diff --git a/SystemTools.cxx b/SystemTools.cxx index 463ff71c385bf61b3fd222f9fd633f84c2b60adf..595bec07b209f11a00ca5f50d1a4b79f798e15a8 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -2893,17 +2893,6 @@ std::string SystemTools::FindDirectory( * the system search path. Returns the full path to the executable if it is * found. Otherwise, the empty string is returned. */ -std::string SystemTools::FindProgram(char const* nameIn, - std::vector const& userPaths, - bool no_system_path) -{ - if (!nameIn || !*nameIn) { - return ""; - } - return SystemTools::FindProgram(std::string(nameIn), userPaths, - no_system_path); -} - std::string SystemTools::FindProgram(std::string const& name, std::vector const& userPaths, bool no_system_path) @@ -2975,105 +2964,6 @@ std::string SystemTools::FindProgram(std::string const& name, return ""; } -std::string SystemTools::FindProgram(std::vector const& names, - std::vector const& path, - bool noSystemPath) -{ - for (std::string const& name : names) { - // Try to find the program. - std::string result = SystemTools::FindProgram(name, path, noSystemPath); - if (!result.empty()) { - return result; - } - } - return ""; -} - -/** - * Find the library with the given name. Searches the given path and then - * the system search path. Returns the full path to the library if it is - * found. Otherwise, the empty string is returned. - */ -std::string SystemTools::FindLibrary(std::string const& name, - std::vector const& userPaths) -{ - // See if the executable exists as written. - if (SystemTools::FileExists(name, true)) { - return SystemTools::CollapseFullPath(name); - } - - // Add the system search path to our path. - std::vector path; - SystemTools::GetPath(path); - // now add the additional paths - path.reserve(path.size() + userPaths.size()); - path.insert(path.end(), userPaths.begin(), userPaths.end()); - // Add a trailing slash to all paths to aid the search process. - for (std::string& p : path) { - if (p.empty() || p.back() != '/') { - p += '/'; - } - } - std::string tryPath; - for (std::string const& p : path) { -#if defined(__APPLE__) - tryPath = p; - tryPath += name; - tryPath += ".framework"; - if (SystemTools::FileIsDirectory(tryPath)) { - return SystemTools::CollapseFullPath(tryPath); - } -#endif -#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__) - tryPath = p; - tryPath += name; - tryPath += ".lib"; - if (SystemTools::FileExists(tryPath, true)) { - return SystemTools::CollapseFullPath(tryPath); - } -#else - tryPath = p; - tryPath += "lib"; - tryPath += name; - tryPath += ".so"; - if (SystemTools::FileExists(tryPath, true)) { - return SystemTools::CollapseFullPath(tryPath); - } - tryPath = p; - tryPath += "lib"; - tryPath += name; - tryPath += ".a"; - if (SystemTools::FileExists(tryPath, true)) { - return SystemTools::CollapseFullPath(tryPath); - } - tryPath = p; - tryPath += "lib"; - tryPath += name; - tryPath += ".sl"; - if (SystemTools::FileExists(tryPath, true)) { - return SystemTools::CollapseFullPath(tryPath); - } - tryPath = p; - tryPath += "lib"; - tryPath += name; - tryPath += ".dylib"; - if (SystemTools::FileExists(tryPath, true)) { - return SystemTools::CollapseFullPath(tryPath); - } - tryPath = p; - tryPath += "lib"; - tryPath += name; - tryPath += ".dll"; - if (SystemTools::FileExists(tryPath, true)) { - return SystemTools::CollapseFullPath(tryPath); - } -#endif - } - - // Couldn't find the library. - return ""; -} - std::string SystemTools::GetRealPath(std::string const& path, std::string* errorMessage) { @@ -3380,33 +3270,6 @@ bool SystemTools::SplitProgramPath(std::string const& in_name, return true; } -bool SystemTools::FindProgramPath(char const* argv0, std::string& pathOut, - std::string& errorMsg) -{ - std::vector failures; - std::string self = argv0 ? argv0 : ""; - failures.push_back(self); - SystemTools::ConvertToUnixSlashes(self); - self = SystemTools::FindProgram(self); - if (!SystemTools::FileIsExecutable(self)) { - failures.push_back(self); - std::ostringstream msg; - msg << "Can not find the command line program "; - msg << "\n"; - if (argv0) { - msg << " argv[0] = \"" << argv0 << "\"\n"; - } - msg << " Attempted paths:\n"; - for (std::string const& ff : failures) { - msg << " \"" << ff << "\"\n"; - } - errorMsg = msg.str(); - return false; - } - pathOut = self; - return true; -} - static void SystemToolsAppendComponents( std::vector& out_components, std::vector::iterator first, diff --git a/SystemTools.hxx.in b/SystemTools.hxx.in index c47888e1184b07bc5398beb2be3a81b5ec6b19b6..daf6ba3c65814daf7cfb8048256c51dd65d75da4 100644 --- a/SystemTools.hxx.in +++ b/SystemTools.hxx.in @@ -382,21 +382,6 @@ public: static bool SplitProgramPath(std::string const& in_name, std::string& dir, std::string& file, bool errorReport = true); - /** - * Given argv[0] for a unix program find the full path to a running - * executable. argv0 can be null for windows WinMain programs - * in this case GetModuleFileName will be used to find the path - * to the running executable. If argv0 is not a full path, - * then this will try to find the full path. If the path is not - * found false is returned, if found true is returned. An error - * message of the attempted paths is stored in errorMsg. - * exeName is the name of the executable. - * buildDir is a possibly null path to the build directory. - * installPrefix is a possibly null pointer to the install directory. - */ - static bool FindProgramPath(char const* argv0, std::string& pathOut, - std::string& errorMsg); - /** * Given a path to a file or directory, convert it to a full path. * This collapses away relative paths relative to the cwd argument @@ -726,24 +711,10 @@ public: /** * Find an executable in the system PATH, with optional extra paths */ - static std::string FindProgram( - char const* name, - std::vector const& path = std::vector(), - bool no_system_path = false); static std::string FindProgram( std::string const& name, std::vector const& path = std::vector(), bool no_system_path = false); - static std::string FindProgram( - std::vector const& names, - std::vector const& path = std::vector(), - bool no_system_path = false); - - /** - * Find a library in the system PATH, with optional extra paths - */ - static std::string FindLibrary(std::string const& name, - std::vector const& path); /** * Return true if the file is a directory