Boost logo

Boost Users :

From: John.Wismar_at_[hidden]
Date: 2003-11-19 17:44:43


I'm using the fielsystem library's directory_iterator class to collect
information about the files in a directory. I'm using VC7.0, and Boost
1.30.2.

My logic looks something like this:

----------------------------------------------------------------------
class DirInfo
{
public:
    DirInfo(fs::path aPath) : myPath(aPath){}
    void scan();
    void addFile(fs::path);
private:
   fs::path myPath;
}

void DirInfo::scan ()
{
    fs::directory_iterator itEnd;
    for (fs::directory_iterator it(myPath); it != itEnd; ++it)
    {
        TRACE("File: %s\n", it->string().c_str());
        if (!fs::is_directory(*it))
        {
            addFile(*it);
        }
    }
}

DirInfo di(fs::path("C:\\temp\\", fs::native);
di.scan();
----------------------------------------------------------

This successfully goes through all of the files (and subdirectories) in the
given directory, but after the last item, the next call to
fs::directory_iterator::operator ++() never returns. If anyone has any
suggestions or ideas, I would love to hear them!! Thanks!

The call stack at the point where execution seems to lock up looks like
this:

      ntdll.dll!NtDelayExecution() + 0xc
      kernel32.dll!_Sleep_at_4() + 0xb

MyApp.exe.exe!boost::detail::lightweight_mutex::scoped_lock::scoped_lock(boost::detail::lightweight_mutex
 & m={...}) Line 96 + 0xa C++
      MyApp.exe.exe!boost::detail::sp_counted_base::release() Line 132 +
0xf C++
      MyApp.exe.exe!boost::detail::shared_count::~shared_count() Line 380
C++

MyApp.exe.exe!boost::shared_ptr<boost::filesystem::directory_iterator::dir_itr_imp>::
~shared_ptr<boost::filesystem::directory_iterator::dir_itr_imp>() + 0x2e
C++

MyApp.exe.exe!boost::shared_ptr<boost::filesystem::directory_iterator::dir_itr_imp>::reset
() Line 217 C++
      MyApp.exe.exe!boost::filesystem::directory_iterator::m_inc() Line
256 C++
> MyApp.exe.exe!boost::filesystem::directory_iterator::operator++()
Line 88 + 0x2b C++
      MyApp.exe.exe!DirInfo::scan() Line 63 + 0x1a C++

---------------------
John Wismar
john.wismar_at_[hidden]


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net