Re: printing out the full path

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, here is another try, cann't figure out whats wrong. any idea why? thanks #include "/usr/include/boost/filesystem/operations.hpp" #include "/usr/include/boost/filesystem/fstream.hpp" #include "/usr/include/boost/filesystem/path.hpp" #include <iostream> #include <string> namespace fs = boost::filesystem; int main(){ fs::path full_path( fs::initial_path() ); char* some_path = "/home/sam/"; full_path = fs::system_complete( fs::path( some_path, fs::native ) ); fs::directory_iterator end_itr; for ( fs::directory_iterator itr( full_path ); itr != end_itr; ++itr ) { std::cout << full_path.native_file_string() << std::endl; } } __________________________________ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail

On Mon, 13 Sep 2004 08:56:38 -0700 (PDT), Fred J. <phddas@yahoo.com> 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@gmail.com
participants (2)
-
Caleb Epstein
-
Fred J.