Re: [Boost-bugs] [Boost C++ Libraries] #8946: filesystem::directory_iterator returns incorrect listing

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #8946: filesystem::directory_iterator returns incorrect listing
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-08-03 16:03:51


#8946: filesystem::directory_iterator returns incorrect listing
-------------------------------+--------------------------------
  Reporter: l.alebarde@… | Owner: bemandawes
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: filesystem
   Version: Boost 1.54.0 | Severity: Problem
Resolution: | Keywords: directory_iterator
-------------------------------+--------------------------------

Comment (by nikita.trophimov@…):

 You need to increment bfs_dir_i after all of the actions in the loop:

 {{{
 #include <iostream>
 #include <stdio.h>
 #include <boost/filesystem.hpp>

 using namespace std;
 namespace bfs = boost::filesystem;

 int main () {
         system("mkdir mydir");
         system("touch mydir/file1");
         system("touch mydir/file2");
         bfs::directory_iterator bfs_dir_i_end;
         bfs::directory_iterator bfs_dir_i("mydir");
         while (bfs_dir_i != bfs_dir_i_end) {
                 bfs::file_type type = (*bfs_dir_i).status().type();
                 bfs::path source = (*bfs_dir_i).path();
                 cout << source << " " << type << endl;
                 ++bfs_dir_i;
         }
 }
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8946#comment:3>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:13 UTC