Boost logo

Boost Users :

From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2008-04-01 15:42:57


Silvio,

you have to implement it yourself. You could use a boost regular expression
lib or xpressive lib, to match mask(s) with file names found. I would
suggest to take a look at boost iterator lib. Using the regex to match the
mask + wrapping the directory_iterator into filetered_iterator will do the
job.

Best Regards,
Ovanes

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

> Hi all!
> I'm trying to learn how to use boost and for a first exercise I chose to
> create a class to perform files enumeration.
> The code below works fine but I didn't find a way to set a search mask
> with wild card, example: *.jpeg or test???.*
> How can I do it?
>
> //-------------------------------------------------------------------
> VOID CFileSearch::InternalSearch( path RootDir, string Mask )
> {
> directory_iterator EndDirItr;
> string OutPut;
> for ( directory_iterator DirItr( RootDir ); DirItr != EndDirItr;
> ++DirItr )
> {
> if ( is_regular( DirItr->status() ) )
> {
> m_FileCount++;
> OutPut = "FILE: " + DirItr->path().string();
> _tprintf( _T( "%s\n" ), OutPut.c_str() );
> }
> else
> {
> InternalSearch( DirItr->path(), Mask );
> }
> }
> }
>
> //-------------------------------------------------------------------
> VOID CFileSearch::Search( string RootDir, string Mask )
> {
> path TempRootDir = system_complete( path( RootDir, native ) );
> if ( exists( TempRootDir ) == true )
> {
> InternalSearch( TempRootDir, Mask );
> _tprintf( _T( "%d files found\n" ), m_FileCount );
> }
> }
>
> _______________________________________________
> 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