Boost logo

Boost Users :

From: Caleb Epstein (caleb.epstein_at_[hidden])
Date: 2004-09-13 12:54:56


On Mon, 13 Sep 2004 08:56:38 -0700 (PDT), Fred J. <phddas_at_[hidden]> wrote:
> I think I gave up, I tried every thing and read all I
> can, I am not able to print out the full path for
> files in a given directroy,

You need to make use of the directory_iterator to get the path of each
file. Something like this:

#include <iostream>
#include <string>

#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/filesystem/path.hpp>

using namespace std;
using namespace boost::filesystem;

int main()
{
    path full_path( initial_path() );
    const char* some_path = getenv ("HOME");
    full_path = system_complete (path (some_path, native));

    for (directory_iterator i (full_path); i != directory_iterator(); ++i)
        cout << i->native_file_string() << endl;
}

-- 
Caleb Epstein
caleb.epstein_at_[hidden]

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