/* ImageDirIterator.h * * Copyright (c) 2007 Machine Perception Laboratory * University of California San Diego. * Authors: Andrew Salamon * */ #include #include "boost/filesystem/path.hpp" #include "boost/filesystem/operations.hpp" namespace bf = boost::filesystem; /** A simple iterator that returns all files in a given directory. * It no longer tries to verify that any given file is an image. * It does NOT recursively descend into sub-directories and does not return any paths for sub-directories. */ class ImageDirIterator { public: static std::string getExtension( const std::string &fname ); ImageDirIterator( const std::string dir ); ~ImageDirIterator(); bool operator++(); bool operator++(int); std::string operator*() const; private: std::string currentPath; bf::path directory; bf::directory_iterator dirIterator; bf::directory_iterator endIterator; bool validExtension( std::string &fname ); };