libzypp  10.5.0
Glob.cc
Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #include <iostream>
00013 #include "zypp/base/LogTools.h"
00014 
00015 #include "zypp/Glob.h"
00016 
00017 using std::endl;
00018 
00020 namespace zypp
00021 { 
00022 
00023   namespace filesystem
00024   { 
00025 
00026     int Glob::add( const char * pattern_r, Flags flags_r )
00027     {
00028       static Flags _APPEND( GLOB_APPEND ); // not published
00029       if ( ! flags_r )
00030         flags_r = _defaultFlags;
00031       if ( _result )
00032         flags_r |= _APPEND;
00033       else
00034         _result.reset( new ::glob_t );
00035       return( _lastGlobReturn = ::glob( pattern_r, flags_r, NULL, &(*_result) ) );
00036     }
00037 
00038     void Glob::clear()
00039     {
00040       if ( _result )
00041       {
00042         ::globfree( &(*_result) );
00043         _result.reset();
00044         _lastGlobReturn = 0;
00045       }
00046     }
00047 
00048     /******************************************************************
00049     **
00050     **  FUNCTION NAME : operator<<
00051     **  FUNCTION TYPE : std::ostream &
00052     */
00053     std::ostream & operator<<( std::ostream & str, const Glob & obj )
00054     {
00055       return dumpRange( str << "(" << obj.size() << ")", obj.begin(), obj.end() );
00056     }
00057 
00059   } // namespace filesystem
00062 } // namespace zypp