/* listdir * * Small example application which lists all files in a given directory and its * subdirectories. * * It demonstrates the use of the ostream_iterator with the * filesystem::file_iterator. */ /* Note: Do not include config.h in your own programs. See README. */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include using namespace std ; int main (int argc, char** argv) { if (argc != 2) { cerr << "Usage: listdir /some/directory" << endl ; return -1 ; } string dir (argv[1]) ; filesystem::file_iterator<> i (dir); // The file_iterator does not provide the top-level directory during // iterations, so we output it by hand: cout << i.currentDirectory () << endl ; copy (i, i.end (), ostream_iterator (cout, "\n")) ; return 0 ; }