I need to recursively search files into one directory and its subdirectory but I want to exclude one path (with its files and subdirectory) from the search.
I'm using std::experimental::filesystem::recursive_directory_iterator
and pop()
modifier but it doesn't work. Where I'm wrong?
void search(const char* pathToSearch,const char* pathToExclude){
std::experimental::filesystem::recursive_directory_iterator iterator(pathToSearch);
for (auto& p : iterator) {
if (p.path() == std::experimental::filesystem::directory_entry(pathToExclude).path()) iterator.pop();
if (fs::is_directory(p)) continue; //exclude directory from output
else std::cout << p << std::endl;
}
}