1 #include "boost/filesystem.hpp" 10 namespace bfs = boost::filesystem;
17 bool const match_full_path)
19 bfs::path path{path_name};
20 if (
exists(path) && is_directory(path)) {
21 std::vector<std::string> v;
22 for (
auto const&
x : bfs::directory_iterator(path)) {
23 if (match_full_path) {
24 auto const str = canonical(
x.path()).
string();
25 if (
str.
find(pattern_to_match) != 0) {
28 std::cout <<
str <<
' ';
30 auto const str = canonical(
x.path()).
filename().string();
31 if (
str.
find(pattern_to_match) != 0) {
34 std::cout <<
str <<
' ';
51 auto const last_slash = to_match.find(
"/");
52 bool const slash_found{last_slash != std::string::npos};
55 to_match.erase(0, last_slash + 1);
58 if (spec.empty() || spec[0] ==
'/') {
59 print_paths(
"/"s + prefix,
"/"s + to_match,
true);
63 print_paths(
"./"s + prefix, to_match,
false);
66 if (spec[0] !=
'/' && spec.find(
"./") != 0) {
69 std::vector<std::string> paths;
71 for (
auto const& path : paths) {
74 print_paths(path + prefix, to_match,
false);
int main(int argc, char **argv)
int find(char c, int index=0, bool cs=TRUE) const
bool exists(std::string path)
std::string getenv(std::string const &name)
void split(std::string const &s, char c, OutIter dest)