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
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.athttp://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.
On 26 June 2013 07:48, Kelly, Dan
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
I apologies for not being clear. The following pastie has the code nicely formatted ... http://pastie.org/8082749 ... The directory iterator where I specify the path location as a string literal works. I can printout the contents of the directory. The directory iterator with the path specified as part of a vector of strings does not. It throws a no such file or directory error. The vector itself is properly defined and verified to have the correct contents. I am using boost 1.53.0. end_itr has been defined in the for loop. I am working off the boost filesystem tutorials. Thanks. -- 0 1 0 0 0 1 1 1 1
On 6/26/2013 11:37 AM, Sarma Tangirala wrote:
On 26 June 2013 07:48, Kelly, Dan
mailto:Dan.Kelly@sig.com> wrote:
[snip]
... Could you provide a more complete example?
This is the key part of Dan's reply. Provide a complete "simplified" compiling example demonstrating the problem. Doing so will get you a better responses... if not itself making the problem apparent during the process. Jeff
I apologize again. The minimum working example works for the directory in
question but in the code I am working on it refuses to do so. I guess this
is a error on my part. I will check.
Thank you.
On 26 June 2013 12:40, Jeff Flinn
On 6/26/2013 11:37 AM, Sarma Tangirala wrote:
On 26 June 2013 07:48, Kelly, Dan
mailto:Dan.Kelly@sig.com> wrote: [snip]
... Could you provide a more complete example?
This is the key part of Dan's reply. Provide a complete "simplified" compiling example demonstrating the problem. Doing so will get you a better responses... if not itself making the problem apparent during the process.
Jeff
______________________________**_________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/**mailman/listinfo.cgi/boost-**usershttp://lists.boost.org/mailman/listinfo.cgi/boost-users
-- 0 1 0 0 0 1 1 1 1
participants (3)
-
Jeff Flinn
-
Kelly, Dan
-
Sarma Tangirala