Boost logo

Boost Users :

From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2008-04-15 07:28:08


Hi!

Just a question:
Did you run your code in debugger to see why it fails?

And an idea from the scratch, what happens if the directory found is either
. or ..? May be you should skip them?

Best Regards,
Ovanes

On Tue, Apr 15, 2008 at 1:19 PM, Silvio Reis Junior <sreisjr_at_[hidden]>
wrote:

> 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 mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>



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