This file is indexed.

/usr/include/x86_64-linux-gnu/zypp/Glob.h is in libzypp-dev 14.29.1-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
/*---------------------------------------------------------------------\
|                          ____ _   __ __ ___                          |
|                         |__  / \ / / . \ . \                         |
|                           / / \ V /|  _/  _/                         |
|                          / /__ | | | | | |                           |
|                         /_____||_| |_| |_|                           |
|                                                                      |
\---------------------------------------------------------------------*/
/** \file	zypp/Glob.h
 *
*/
#ifndef ZYPP_GLOB_H
#define ZYPP_GLOB_H

extern "C"
{
#include <glob.h>
}

#include <iosfwd>

#include "zypp/base/Easy.h"
#include "zypp/base/Flags.h"
#include "zypp/base/Iterator.h"
#include "zypp/base/NonCopyable.h"
#include "zypp/base/DefaultIntegral.h"

#include "zypp/Pathname.h"

///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////

  ///////////////////////////////////////////////////////////////////
  namespace filesystem
  { /////////////////////////////////////////////////////////////////

    ///////////////////////////////////////////////////////////////////
    //
    //	CLASS NAME : Glob
    //
    /** Find pathnames matching a pattern.
     * \code
     * Glob glob( Glob::_BRACE );
     * glob.add( "/somewhere/solverTestcase/ *{.xml,.xml.gz}" );
     * glob.add( "/somewhere/else/a*" );
     * for_( it, glob.begin(), glob.end() )
     *   ...
     * \endcode
     * \code
     * std::list<Pathname> plist;
     * Glob::collect( "/somewherre/solverTestcase/ *{.xml,.xml.gz}", Glob::_BRACE,
     *                std::back_inserter( plist ) );
     * \endcode
     * \see Manual page glob(3)
     */
    class Glob : private base::NonCopyable
    {
      public:
        typedef size_t size_type;
        typedef const char * value_type;

        /** Iterate NULL terminated \c char* array. */
        class const_iterator : public boost::iterator_adaptor<
              const_iterator                // Derived
            , char **                       // Base
            , value_type                    // Value
            , boost::forward_traversal_tag  // CategoryOrTraversal
            , const value_type              // Reference
            >
        {
          public:
            const_iterator()
            : const_iterator::iterator_adaptor_( 0 )
            {}

            explicit const_iterator( char ** _idx )
            : const_iterator::iterator_adaptor_( _idx && *_idx ? _idx : 0 )
            {}

          private:
            friend class boost::iterator_core_access;
            void increment()
            {
              if ( base_reference() && !*(++base_reference()) )
                base_reference() = 0;
            }
            reference dereference() const
            { return( base() ? *base() : 0 ); }
        };
        ///////////////////////////////////////////////////////////////////

      public:
        /** Individual bits to combine in \ref Flags. */
        enum Bits {
          _ERR		= GLOB_ERR,		//!< Return on read errors.
          _MARK		= GLOB_MARK,		//!< Append a slash to each name.
          _NOSORT	= GLOB_NOSORT,		//!< Don't sort the names.
          // unsupported _DOOFFS = GLOB_DOOFFS,	//!< Insert PGLOB->gl_offs NULLs.
          _NOCHECK	= GLOB_NOCHECK,		//!< If nothing matches, return the pattern.
          // autoapplied _APPEND = GLOB_APPEND,	//!< Append to results of a previous call.
          _NOESCAPE	= GLOB_NOESCAPE,	//!< Backslashes don't quote metacharacters.
          _PERIOD	= GLOB_PERIOD,		//!< Leading `.' can be matched by metachars.
          // unsupported _MAGCHAR = GLOB_MAGCHAR,//!< Set in gl_flags if any metachars seen.
          _ALTDIRFUNC	= GLOB_ALTDIRFUNC,	//!< Use gl_opendir et al functions.
          _BRACE	= GLOB_BRACE,		//!< Expand "{a,b}" to "a" "b".
          _NOMAGIC	= GLOB_NOMAGIC,		//!< If no magic chars, return the pattern.
          _TILDE	= GLOB_TILDE,		//!< Expand ~user and ~ to home directories.
          _ONLYDIR	= GLOB_ONLYDIR,		//!< Match only directories.
          _TILDE_CHECK	= GLOB_TILDE_CHECK,	//!< Like GLOB_TILDE but return an error if the user name is not available.
        };

        /** type Flags: Type-safe OR-combination of \ref Bits. */
        ZYPP_DECLARE_FLAGS( Flags, Bits );

      public:
        /** Default ctor optionally taking the default flags.
         * The flags passed here are the default for \ref add.
         * \see \ref setDefaultFlags
        */
        Glob( Flags flags_r = Flags() )
        : _defaultFlags( flags_r )
        {}

        /** Ctor adding pathnames matching \a pattern_r.
         * The flags passed here are the default for \ref add.
         * \see \ref setDefaultFlags
        */
        explicit Glob( const Pathname & pattern_r, Flags flags_r = Flags() )
        : _defaultFlags( flags_r )
        { add( pattern_r, flags_r ); }
        /** \overload */
        explicit Glob( const std::string & pattern_r, Flags flags_r = Flags() )
        : _defaultFlags( flags_r )
        { add( pattern_r, flags_r ); }
        /** \overload */
        explicit Glob( const char * pattern_r, Flags flags_r = Flags() )
        : _defaultFlags( flags_r )
        { add( pattern_r, flags_r ); }

        /** Dtor */
        ~Glob()
        { if ( _result ) ::globfree( &(*_result) ); }

        /** Add pathnames matching \a pattern_r to the current result.
         *
         * Any flags passed here override the global default passed to
         * the ctor. GLOB_APPEND is atomatically added to the flags
         * f needed.
         *
         * This invalidates all iterators.
         * \see \ref setDefaultFlags
         * \return the value returned by ::glob().
         */
        int add( const Pathname & pattern_r, Flags flags_r = Flags() )
        { return add( pattern_r.c_str(), flags_r ); }
        /** \overload */
        int add( const std::string & pattern_r, Flags flags_r = Flags() )
        { return add( pattern_r.c_str(), flags_r ); }
        /** \overload */
        int add( const char * pattern_r, Flags flags_r = Flags() );

        /** Clear all results found so far. \ref defaultFlags remain active. */
        void clear();

        /** Clear all results and reset \ref defaultFlags. */
        void reset( Flags flags_r = Flags() )
        { clear(); setDefaultFlags( flags_r ); }


      public:
        /** The default flags passed to \c ::glob(). */
        Flags defaultFlags() const
        { return _defaultFlags; }

        /** Set the default flags passed to \c ::glob(). */
        void setDefaultFlags( Flags flags_r = Flags() )
        { _defaultFlags = flags_r; }

        /** Returns the value returned by the last call to \c ::glob().
         * \c Zero on successful completion. Otherwise \c GLOB_NOSPACE or \c GLOB_ABORTED
         * or \c GLOB_NOMATCH.
         */
        int lastGlobReturn() const
        { return _lastGlobReturn; }

      public:
        /** Whether matches were found. */
        bool empty() const
        { return ! ( _result && _result->gl_pathc ); }

        /** The number of matches found so far. */
        size_type size() const
        { return( _result ? _result->gl_pathc : 0 ); }

        /** Iterator pointing to the first result. */
        const_iterator begin() const
        { return( _result ? const_iterator( _result->gl_pathv ) : const_iterator() ); }

        /** Iterator pointing behind the last result. */
        const_iterator end() const
        { return const_iterator(); }

      public:

        /** \name Collecting Glob results to some _OutputIterator
         * \code
         * std::list<Pathname> p;
         * Glob::collect( "/bin/a*.dat}", std::back_inserter(p) );
         * Glob::collect( "/bin/a*{.xml,.xml.gz}", Glob::_BRACE, std::back_inserter(p) );
         * \endcode
         */
        //@{
        /** Write glob result to some \c OutputIterator. */
        template<class _OutputIterator>
        static int collect( const Pathname & pattern_r, _OutputIterator result_r )
        { return collect( pattern_r.c_str(), Flags(), result_r ); }
        /** \overload */
        template<class _OutputIterator>
        static int collect( const std::string & pattern_r, _OutputIterator result_r )
        { return collect( pattern_r.c_str(), Flags(), result_r ); }
        /** \overload */
        template<class _OutputIterator>
        static int collect( const char * pattern_r, _OutputIterator result_r )
        { return collect( pattern_r, Flags(), result_r ); }

        /** \overload With \ref Flags */
        template<class _OutputIterator>
        static int collect( const Pathname & pattern_r, Flags flags_r, _OutputIterator result_r )
        { return collect( pattern_r.c_str(), flags_r, result_r ); }
        /** \overload */
        template<class _OutputIterator>
        static int collect( const std::string & pattern_r, Flags flags_r, _OutputIterator result_r )
        { return collect( pattern_r.c_str(), flags_r, result_r ); }
        /** \overload */
        template<class _OutputIterator>
        static int collect( const char * pattern_r, Flags flags_r, _OutputIterator result_r )
        {
          Glob glob( pattern_r, flags_r );
          if ( glob.lastGlobReturn() == 0 )
            for_( it, glob.begin(), glob.end() )
              (*result_r)++ = typename _OutputIterator::container_type::value_type(*it);
          return glob.lastGlobReturn();
        }
        //@}

      private:
        Flags _defaultFlags;
        scoped_ptr< ::glob_t> _result;
        DefaultIntegral<int,0> _lastGlobReturn;
    };
    ///////////////////////////////////////////////////////////////////

    /** \relates Glob Stream output */
    std::ostream & operator<<( std::ostream & str, const Glob & obj );

    /** \relates Glob::const_iterator Stream output */
    inline std::ostream & operator<<( std::ostream & str, const Glob::const_iterator & obj )
    { return str << *obj; }

    ZYPP_DECLARE_OPERATORS_FOR_FLAGS( Glob::Flags );

    ///////////////////////////////////////////////////////////////////

    /////////////////////////////////////////////////////////////////
  } // namespace filesystem
  ///////////////////////////////////////////////////////////////////
  /////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#endif // ZYPP_GLOB_H