Boost logo

Boost Users :

From: Brad (boost_at_[hidden])
Date: 2008-04-24 04:41:22


Mohan gupta wrote:
> hello every one,
> can anyone please tell me is there any way to find the files in a
> directory with some exension say .txt,.doc, .cpp etc ......and then
> use them ????
> all help is appreciated
> mohan gupta
namespace bfs=boost::filesystem;

bfs::path p("/home/user/folder");
bfs::directory_iterator dir_iter(p), dir_end;
for(;dir_iter != dir_end; ++dir_iter)
{
    if( bfs::extension(*dir_iter) == ".txt" )
        do_something();
    elseif( bfs::extension(*dir_iter) == ".doc" )
         do_something_different();
}

For the most part not my code :-)

Cheers,
Brad



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net