11 #include <boost/filesystem.hpp>
12 #include <boost/tokenizer.hpp>
14 #include <sys/types.h>
20 static std::map<std::string, std::string>
g_cache;
26 namespace fs = boost::filesystem;
33 std::vector<std::string> sp;
38 char* env_cmake = getenv(
"CMAKE_PREFIX_PATH");
41 std::string cmakePath = env_cmake;
42 boost::char_separator<char> sep(
":");
43 boost::tokenizer<boost::char_separator<char>> tok(cmakePath, sep);
48 if(!fs::exists(path /
".catkin"))
81 for(fs::recursive_directory_iterator it(path); it != fs::recursive_directory_iterator(); ++it)
83 if(it->path().filename() == name
84 && fs::is_regular_file(it->path())
85 && access(it->path().c_str(), X_OK) == 0)
87 return it->path().string();
94 static std::string
_getExecutable(
const std::string& package,
const std::string& name)
102 fs::path workspacePath(workspace);
104 fs::path execPath = workspacePath /
"lib" /
package / name;
105 if(fs::exists(execPath) && access(execPath.c_str(), X_OK) == 0)
106 return execPath.string();
109 if(!sharePath.empty())
115 if(!packageDir.empty())
119 return std::string();
124 std::pair<std::string, std::string> key(
package, name);
144 fs::path workspacePath(workspace);
146 fs::path execPath = workspacePath /
"lib" /
package;
147 fs::path filePath = execPath / name;
148 if(fs::exists(filePath) && access(filePath.c_str(), X_OK) == 0)
149 return execPath.string();
151 fs::path sharePath = workspacePath /
"share" /
package;
152 filePath = sharePath / name;
153 if(fs::exists(filePath) && access(filePath.c_str(), X_OK) == 0)
154 return sharePath.string();
159 fs::path filePath = packageDir / name;
160 if(fs::exists(filePath) && access(filePath.c_str(), X_OK) == 0)
161 return packageDir.string();
164 return std::string();