yifeikong
11/21/2014 - 6:30 AM

boost glob

#include <boost/filesystem.hpp>

namespace fs = boost::filesystem;

struct recursive_directory_range
{

    typedef fs::recursive_directory_iterator iterator;
    recursive_directory_range(fs::path p) : p_(p) {}

    iterator begin() { return fs::recursive_directory_iterator(p_); }
    iterator end() { return fs::recursive_directory_iterator(); }

    fs::path p_;
};


int main (int argc, char * argv[])
{
    for (auto it : recursive_directory_range("D:\\babun-1.0.1"))
    {
        if (fs::extension(it) == std::string(".zip")) {
            std::cout << it << std::endl;
        }
    }
    getchar();
}