Mailinglist Archive: zypp-commit (266 mails)

< Previous Next >
[zypp-commit] r11708 - in /trunk/libzypp: CMakeLists.txt VERSION.cmake package/libzypp.changes zypp/CMakeLists.txt zypp/Glob.cc zypp/Glob.h
  • From: mlandres@xxxxxxxxxxxxxxxx
  • Date: Tue, 18 Nov 2008 17:45:20 -0000
  • Message-id: <20081118174520.597E09E4BA@xxxxxxxxxxxxxxxx>
Author: mlandres
Date: Tue Nov 18 18:45:19 2008
New Revision: 11708

URL: http://svn.opensuse.org/viewcvs/zypp?rev=11708&view=rev
Log:
- Linking libexpat required to support loading helix files.
- Add class filesystem::Glob to find pathnames matching a pattern
by using ::glob.

Added:
trunk/libzypp/zypp/Glob.cc
trunk/libzypp/zypp/Glob.h
Modified:
trunk/libzypp/CMakeLists.txt
trunk/libzypp/VERSION.cmake
trunk/libzypp/package/libzypp.changes
trunk/libzypp/zypp/CMakeLists.txt

Modified: trunk/libzypp/CMakeLists.txt
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/CMakeLists.txt?rev=11708&r1=11707&r2=11708&view=diff
==============================================================================
--- trunk/libzypp/CMakeLists.txt (original)
+++ trunk/libzypp/CMakeLists.txt Tue Nov 18 18:45:19 2008
@@ -114,6 +114,9 @@
INCLUDE_DIRECTORIES( ${SATSOLVER_INCLUDE_DIR} )
ENDIF( NOT SATSOLVER_FOUND )

+# satsolver uses expat and has open references to it:
+FIND_PACKAGE(EXPAT REQUIRED)
+
FIND_PACKAGE(OpenSSL REQUIRED)

FIND_PROGRAM( DOXYGEN doxygen )

Modified: trunk/libzypp/VERSION.cmake
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/VERSION.cmake?rev=11708&r1=11707&r2=11708&view=diff
==============================================================================
--- trunk/libzypp/VERSION.cmake (original)
+++ trunk/libzypp/VERSION.cmake Tue Nov 18 18:45:19 2008
@@ -61,7 +61,7 @@
SET(LIBZYPP_MAJOR "5")
SET(LIBZYPP_COMPATMINOR "23")
SET(LIBZYPP_MINOR "24")
-SET(LIBZYPP_PATCH "0")
+SET(LIBZYPP_PATCH "1")
#
# LAST RELEASED: 5.23.0 (23)
# (The number in parenthesis is LIBZYPP_COMPATMINOR)

Modified: trunk/libzypp/package/libzypp.changes
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/package/libzypp.changes?rev=11708&r1=11707&r2=11708&view=diff
==============================================================================
--- trunk/libzypp/package/libzypp.changes (original)
+++ trunk/libzypp/package/libzypp.changes Tue Nov 18 18:45:19 2008
@@ -1,4 +1,11 @@
-------------------------------------------------------------------
+Tue Nov 18 18:37:30 CET 2008 - ma@xxxxxxx
+
+- Add class filesystem::Glob to find pathnames matching a pattern
+ by using ::glob.
+- revision 11708
+
+-------------------------------------------------------------------
Thu Nov 13 11:07:56 CET 2008 - schubi@xxxxxxx

- Taking care for ppc64 while distupgrade (bnc #443685)

Modified: trunk/libzypp/zypp/CMakeLists.txt
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/CMakeLists.txt?rev=11708&r1=11707&r2=11708&view=diff
==============================================================================
--- trunk/libzypp/zypp/CMakeLists.txt (original)
+++ trunk/libzypp/zypp/CMakeLists.txt Tue Nov 18 18:45:19 2008
@@ -24,6 +24,7 @@
ExternalProgram.cc
Fetcher.cc
FileChecker.cc
+ Glob.cc
HistoryLog.cc
IdString.cc
KeyRing.cc
@@ -103,6 +104,7 @@
ExternalProgram.h
Fetcher.h
FileChecker.h
+ Glob.h
HistoryLog.h
IdString.h
IdStringType.h
@@ -868,7 +870,7 @@
TARGET_LINK_LIBRARIES(zypp ${CURL_LIBRARY} )
TARGET_LINK_LIBRARIES(zypp ${LIBXML_LIBRARY} )
TARGET_LINK_LIBRARIES(zypp ${ZLIB_LIBRARY} )
-TARGET_LINK_LIBRARIES(zypp ${SATSOLVER_LIBRARY} )
+TARGET_LINK_LIBRARIES(zypp ${SATSOLVER_LIBRARY} ${EXPAT_LIBRARY})
TARGET_LINK_LIBRARIES(zypp ${OPENSSL_LIBRARIES} )
TARGET_LINK_LIBRARIES(zypp ${CRYPTO_LIBRARIES} )
TARGET_LINK_LIBRARIES(zypp ${SIGNALS_LIBRARY} )

Added: trunk/libzypp/zypp/Glob.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Glob.cc?rev=11708&view=auto
==============================================================================
--- trunk/libzypp/zypp/Glob.cc (added)
+++ trunk/libzypp/zypp/Glob.cc Tue Nov 18 18:45:19 2008
@@ -0,0 +1,53 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/Glob.cc
+ *
+*/
+#include <iostream>
+#include "zypp/base/LogTools.h"
+
+#include "zypp/Glob.h"
+
+using std::endl;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace filesystem
+ { /////////////////////////////////////////////////////////////////
+
+ int Glob::add( const std::string & pattern_r, Flags flags_r )
+ {
+ static Flags _APPEND( GLOB_APPEND ); // not published
+ if ( ! flags_r )
+ flags_r = _defaultFlags;
+ if ( _result )
+ flags_r |= _APPEND;
+ else
+ _result.reset( new ::glob_t );
+ return( _lastGlobReturn = ::glob( pattern_r.c_str(), flags_r, NULL,
&(*_result) ) );
+ }
+
+ /******************************************************************
+ **
+ ** FUNCTION NAME : operator<<
+ ** FUNCTION TYPE : std::ostream &
+ */
+ std::ostream & operator<<( std::ostream & str, const Glob & obj )
+ {
+ return dumpRange( str << "(" << obj.size() << ")", obj.begin(),
obj.end() );
+ }
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace filesystem
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////

Added: trunk/libzypp/zypp/Glob.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/Glob.h?rev=11708&view=auto
==============================================================================
--- trunk/libzypp/zypp/Glob.h (added)
+++ trunk/libzypp/zypp/Glob.h Tue Nov 18 18:45:19 2008
@@ -0,0 +1,217 @@
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ 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"
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ namespace filesystem
+ { /////////////////////////////////////////////////////////////////
+
+ ///////////////////////////////////////////////////////////////////
+ //
+ // CLASS NAME : Glob
+ //
+ /** Find pathnames matching a pattern.
+ * \code
+ * Glob glob( Glob::_BRACE );
+ * glob.add( "/somewherre/solverTestcase/ *{.xml,.xml.gz}" );
+ * \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;
+ }
+ };
+ ///////////////////////////////////////////////////////////////////
+
+ 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.
+ */
+ 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.
+ */
+ explicit Glob( const std::string & 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.
+ *
+ * The flags passed here override the global default passed to
+ * the ctor. GLOB_APPEND is atomatically added to the flags if needed.
+ *
+ * This invalidates all iterators.
+ * \see \ref setDefaultFlags
+ * \return the value returned by ::glob().
+ */
+ int add( const std::string & pattern_r, Flags flags_r = Flags() );
+
+ 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/m*", std::back_inserter(p) );
+ * \endcode
+ */
+ //@{
+ /** Write glob result to some \c OutputIterator. */
+ template<class _OutputIterator>
+ static int collect( const std::string & 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)++ = *it;
+ return glob.lastGlobReturn();
+ }
+ /** \overload */
+ template<class _OutputIterator>
+ static int collect( const std::string & pattern_r, _OutputIterator
result_r )
+ { return collect( pattern_r, Flags(), result_r ); }
+ //@}
+
+ 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 );
+
+ ZYPP_DECLARE_OPERATORS_FOR_FLAGS( Glob::Flags );
+
+ ///////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace filesystem
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_GLOB_H

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages