Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <algorithm>
- #include <functional>
- #include <boost/ref.hpp>
- #include <boost/filesystem.hpp>
- using namespace std;
- using namespace boost::filesystem;
- struct file_search: binary_function<directory_entry, path, bool>
- {
- bool operator()(const directory_entry& file, const path& filename) const
- {
- return file.status().type()==directory_file ?
- find_if(directory_iterator(file), directory_iterator(), bind2nd(file_search(), boost::ref(filename)))!=directory_iterator() :
- file.path().filename()==filename;
- }
- };
- int main()
- {
- path filename, the_path;
- cin >> filename >> the_path;
- if (file_search()(directory_entry(the_path), filename))
- cout << "Found!";
- else
- cout << "Not found!";
- }
Advertisement
Add Comment
Please, Sign In to add comment