libzypp  17.31.0
PathInfo.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
13 #include <zypp/PathInfo.h>
14 #include <zypp/base/StrMatcher.h>
15 
16 using std::endl;
17 using std::string;
18 
20 namespace zypp
21 {
22  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
int dirForEach(const Pathname &dir_r, const StrMatcher &matcher_r, function< bool(const Pathname &, const char *const)> fnc_r)
Definition: PathInfo.cc:32
const StrMatcher & matchNoDots()
Convenience returning StrMatcher( "[^.]*", Match::GLOB )
Definition: PathInfo.cc:26
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1