libzypp: zypp/PathInfo.cc Source File

libzypp 17.38.5

PathInfo.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12
13#include <zypp/PathInfo.h>
14#include <zypp/base/StrMatcher.h>
15
16using std::endl;
17using std::string;
18
20namespace zypp
21{
23 namespace filesystem
24 {
25
26 const StrMatcher & matchNoDots()
27 {
28 static StrMatcher noDots( "[^.]*", Match::GLOB );
29 return noDots;
30 }
31
32 int dirForEach( const Pathname & dir_r, const StrMatcher & matcher_r, function<bool( const Pathname &, const char *const)> fnc_r )
33 {
34 if ( ! fnc_r )
35 return 0;
36
37 bool nodots = ( &matcher_r == &matchNoDots() );
38 return dirForEach( dir_r,
39 [&]( const Pathname & dir_r, const char *const name_r )->bool
40 {
41 if ( ( nodots && name_r[0] == '.' ) || ! matcher_r( name_r ) )
42 return true;
43 return fnc_r( dir_r, name_r );
44 } );
45 }
46
48 } // namespace filesystem
51} // namespace zypp
StrMatcher.h
zypp::Match::GLOB
@ GLOB
Glob.
Definition StrMatcher.h:47
zypp::StrMatcher
String matching (STRING|SUBSTRING|GLOB|REGEX).
Definition StrMatcher.h:298
zypp::filesystem::Pathname
Pathname.
Definition Pathname.h:48
zypp::filesystem
Types and functions for filesystem operations.
Definition Glob.cc:24
zypp::filesystem::matchNoDots
const StrMatcher & matchNoDots()
Convenience returning StrMatcher( "[^.]*", Match::GLOB ).
Definition PathInfo.cc:26
zypp::filesystem::dirForEach
int dirForEach(const Pathname &dir_r, const StrMatcher &matcher_r, function< bool(const Pathname &, const char *const)> fnc_r)
Definition PathInfo.cc:32
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
PathInfo.h