libzypp: zypp/Glob.cc Source File

libzypp 17.38.7

Glob.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#include <iostream>
13#include <zypp-core/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
38 void Glob::clear()
39 {
40 if ( _result )
41 {
42 ::globfree( &(*_result) );
43 _result.reset();
44 _lastGlobReturn = 0;
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
60
62} // namespace zypp
Glob.h
LogTools.h
zypp::filesystem::Glob
Find pathnames matching a pattern.
Definition Glob.h:58
zypp::filesystem::Glob::_result
scoped_ptr< ::glob_t > _result
Definition Glob.h:249
zypp::filesystem::Glob::size
size_type size() const
The number of matches found so far.
Definition Glob.h:193
zypp::filesystem::Glob::begin
const_iterator begin() const
Iterator pointing to the first result.
Definition Glob.h:197
zypp::filesystem::Glob::add
int add(const Pathname &pattern_r, Flags flags_r=Flags())
Add pathnames matching pattern_r to the current result.
Definition Glob.h:155
zypp::filesystem::Glob::_lastGlobReturn
DefaultIntegral< int, 0 > _lastGlobReturn
Definition Glob.h:250
zypp::filesystem::Glob::_defaultFlags
Flags _defaultFlags
Definition Glob.h:248
zypp::filesystem::Glob::clear
void clear()
Clear all results found so far.
Definition Glob.cc:38
zypp::filesystem::Glob::end
const_iterator end() const
Iterator pointing behind the last result.
Definition Glob.h:201
str
String related utilities and Regular expression matching.
zypp::filesystem
Types and functions for filesystem operations.
Definition Glob.cc:24
zypp::filesystem::operator<<
std::ostream & operator<<(std::ostream &str, const Glob &obj)
relates: Glob Stream output
Definition Glob.cc:53
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::dumpRange
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:409