CacheFSCK.cc

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #include <iostream>
00013 #include "zypp/base/Logger.h"
00014 #include "zypp/base/Exception.h"
00015 #include "zypp/cache/CacheFSCK.h"
00016 #include "zypp/cache/sqlite3x/sqlite3x.hpp"
00017 
00018 using namespace zypp;
00019 using namespace zypp::cache;
00020 using namespace std;
00021 using namespace sqlite3x;
00022 
00024 namespace zypp
00025 { 
00026 
00027   namespace cache
00028   { 
00029 
00031     //
00032     //  CLASS NAME : CacheFSCK::Impl
00033     //
00035     struct CacheFSCK::Impl
00036     {
00037 
00038     public:
00039       
00040       Impl( const Pathname &dbdir )
00041         : _dbdir(dbdir)
00042       {
00043   
00044       }
00045       
00046       void start()
00047       {
00048         try
00049         {
00050           sqlite3_connection con((_dbdir + "zypp.db").asString().c_str());
00051           //con.executenonquery("BEGIN;");
00052 
00053           sqlite3_command cmd( con, "PRAGMA integrity_check;");
00054           sqlite3_reader reader = cmd.executereader();
00055           while(reader.read())
00056           {
00057             cout << reader.getstring(0) << endl;
00058           }
00059         }
00060         catch( const std::exception &e )
00061         {
00062           ZYPP_RETHROW(Exception(e.what()));
00063         }
00064       }
00065 
00066     private:
00067       friend Impl * rwcowClone<Impl>( const Impl * rhs );
00069       Impl * clone() const
00070       { return new Impl( *this ); }
00071       
00072       Pathname _dbdir;
00073     };
00075 
00077     inline std::ostream & operator<<( std::ostream & str, const CacheFSCK::Impl & obj )
00078     {
00079       return str << "CacheFSCK::Impl";
00080     }
00081 
00083     //
00084     //  CLASS NAME : CacheFSCK
00085     //
00087 
00089     //
00090     //  METHOD NAME : CacheFSCK::CacheFSCK
00091     //  METHOD TYPE : Ctor
00092     //
00093     CacheFSCK::CacheFSCK( const Pathname &dbdir )
00094     : _pimpl( new Impl(dbdir) )
00095     {}
00096 
00098     //
00099     //  METHOD NAME : CacheFSCK::~CacheFSCK
00100     //  METHOD TYPE : Dtor
00101     //
00102     CacheFSCK::~CacheFSCK()
00103     {}
00104 
00105     void CacheFSCK::start()
00106     {
00107       _pimpl->start();
00108     }
00109     
00110     /******************************************************************
00111     **
00112     **  FUNCTION NAME : operator<<
00113     **  FUNCTION TYPE : std::ostream &
00114     */
00115     std::ostream & operator<<( std::ostream & str, const CacheFSCK & obj )
00116     {
00117       return str << *obj._pimpl;
00118     }
00119 
00121   } // namespace cache
00124 } // namespace zypp

Generated on Tue Sep 25 19:23:00 2007 for libzypp by  doxygen 1.5.3