$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Jeff Garland (jeff_at_[hidden])
Date: 2002-08-14 13:59:50
I'm trying to write a program to list a directory using the filesystem lib and 
I'm running into a couple problems.  First, here's the program:
#include "boost/filesystem/operations.hpp"
#include <iostream>
namespace fs = boost::filesystem;
int main()
{
  try {
  
    fs::path start("/home");
    fs::directory_iterator end_itr;
    fs::directory_iterator dir_itr(start);
    for (;dir_itr != end_itr; ++dir_itr) {
      std::cout << (dir_itr->file_path()) << std::endl;
    }
  }
  catch(std::exception& e) {
    std::cout << e.what() << std::endl;
  }
  return 0;
}
The first problem is that the checking code will not construct "/home" as a 
valid path.  This is a result of invalid_chars containing a '/'.  When I 
remove '/' from the invalid_chars array the construction is allowed to proceed 
as expected.  Seems like "/home" should be allowed on Unix or generically?
The second problem is that the program crashes on a ~directory_iterator
when it calls to the counted_base destructor which fails in free.  I could 
not reproduce the problem by just constructing the iterators so it must have 
something to do with the results of operator++.  Any ideas?
Jeff
PS: This is using g++ 3.0.3.