libzypp 17.31.0
Glob.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#include <iostream>
13#include <zypp/base/LogTools.h>
14
15#include <zypp/Glob.h>
16
17using std::endl;
18
20namespace zypp
21{
23 namespace filesystem
24 {
25
26 int Glob::add( const char * pattern_r, Flags flags_r )
27 {
28 static Flags kAppend( GLOB_APPEND ); // not published
29 if ( ! flags_r )
30 flags_r = _defaultFlags;
31 if ( _result )
32 flags_r |= kAppend;
33 else
34 _result.reset( new ::glob_t );
35 return( _lastGlobReturn = ::glob( pattern_r, flags_r, NULL, &(*_result) ) );
36 }
37
39 {
40 if ( _result )
41 {
42 ::globfree( &(*_result) );
43 _result.reset();
45 }
46 }
47
48 /******************************************************************
49 **
50 ** FUNCTION NAME : operator<<
51 ** FUNCTION TYPE : std::ostream &
52 */
53 std::ostream & operator<<( std::ostream & str, const Glob & obj )
54 {
55 return dumpRange( str << "(" << obj.size() << ")", obj.begin(), obj.end() );
56 }
57
59 } // namespace filesystem
62} // namespace zypp
Find pathnames matching a pattern.
Definition: Glob.h:58
scoped_ptr< ::glob_t > _result
Definition: Glob.h:249
size_type size() const
The number of matches found so far.
Definition: Glob.h:193
const_iterator begin() const
Iterator pointing to the first result.
Definition: Glob.h:197
int add(const Pathname &pattern_r, Flags flags_r=Flags())
Add pathnames matching pattern_r to the current result.
Definition: Glob.h:155
DefaultIntegral< int, 0 > _lastGlobReturn
Definition: Glob.h:250
void clear()
Clear all results found so far.
Definition: Glob.cc:38
const_iterator end() const
Iterator pointing behind the last result.
Definition: Glob.h:201
String related utilities and Regular expression matching.
std::ostream & operator<<(std::ostream &str, const Glob &obj)
Definition: Glob.cc:53
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
std::ostream & dumpRange(std::ostream &str, TIterator begin, TIterator end, const std::string &intro="{", const std::string &pfx="\n ", const std::string &sep="\n ", const std::string &sfx="\n", const std::string &extro="}")
Print range defined by iterators (multiline style).
Definition: LogTools.h:91