Boost logo

Boost Users :

From: Silvio Reis Junior (sreisjr_at_[hidden])
Date: 2008-04-15 07:19:51


Hello friends!
I'm trying to use directory_iterator but when I try to list recursivelly an
entire drive or a big directory I get an unhandled exception.
I'm trying to figure out if I did something wrong but the code is very
similar to the example on the boost web page.
Here is the code:

//-------------------------------------------------------------------
VOID CFileSearch::InternalSearch( path RootDir )
{
    directory_iterator EndDirItr;
    for ( directory_iterator DirItr( RootDir ); DirItr != EndDirItr;
++DirItr )
    {
        if ( is_regular( DirItr->status() ) )
        {
            _tprintf( "FILE: %s\n", DirItr->path().string().c_str() );
        }
        else if ( is_directory( DirItr->status() ) )
        {
            _tprintf( "DIR : %s\n", DirItr->path().string().c_str() );
            InternalSearch( DirItr->path() );
        }
    }
}

//-------------------------------------------------------------------
VOID CFileSearch::Search( string RootDir )
{
    path TempRootDir = system_complete( path( RootDir, native ) );
    if ( exists( TempRootDir ) == true )
    {
        InternalSearch( TempRootDir );
    }
}

//-------------------------------------------------------------------
CFileSearch FileSearch;
FileSearch.Search( "c:\\" );

Is there something wrong in the above code?
Thank you in advance.
Silvio.



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