It is unclear from your example what “doesn’t work.”  Are you having a compilation issue?  Is an exception getting thrown?

 

It is also unclear where end_itr is defined.  Could you provide a more complete example?

 

Dan

 

From: Boost-users [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Sarma Tangirala
Sent: Tuesday, June 25, 2013 20:56
To: boost-users@lists.boost.org
Subject: [Boost-users] Problem Iterating a directory

 

Hello,

I am using boost filesystem to iterate through my directory and have encountered a problem that I am unsure of how to debug.

  try {

    //for ( boostfs::directory_iterator dir(boostfs::path("/home/vtangira/Desktop/person_finder_v20130513/data/dummy1")), end_itr;
    for ( boostfs::directory_iterator dir(boostfs::path(paths_to_files.at(0).c_str())), end_itr;
          dir != end_itr;
          dir++
        ) {

        std::cout << "File: " << dir->path() << std::endl;
    }  

  } catch (boostfs::filesystem_error e) {
      cout << "Error Code: " << e.code() << endl
             << "Error Msg: " << e.code().message() << endl;
    }  

In this snippet, the line with the for loop that has been commented out works but the the one below it with the vector does not. The vector version represents the same string.

Any advice is appreciated.

Thanks




--
0 1 0

0 0 1

1 1 1




IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.