00001 /*---------------------------------------------------------------------\ 00002 | | 00003 | __ __ ____ _____ ____ | 00004 | \ \ / /_ _/ ___|_ _|___ \ | 00005 | \ V / _` \___ \ | | __) | | 00006 | | | (_| |___) || | / __/ | 00007 | |_|\__,_|____/ |_| |_____| | 00008 | | 00009 | core system | 00010 | (C) SuSE GmbH | 00011 \----------------------------------------------------------------------/ 00012 00013 File: binHeaderCache.h 00014 00015 Author: Michael Andres <ma@suse.de> 00016 Maintainer: Michael Andres <ma@suse.de> 00017 00018 Purpose: 00019 00020 /-*/ 00021 #ifndef binHeaderCache_h 00022 #define binHeaderCache_h 00023 00024 #include <iosfwd> 00025 00026 #include <y2util/Pathname.h> 00027 00028 #include <y2pm/binHeaderPtr.h> 00029 00031 // 00032 // CLASS NAME : binHeaderCache 00036 class binHeaderCache { 00037 00038 friend std::ostream & operator<<( std::ostream & str, const binHeaderCache & obj ); 00039 00040 binHeaderCache & operator=( const binHeaderCache & ); 00041 binHeaderCache ( const binHeaderCache & ); 00042 00043 public: 00044 00045 typedef unsigned pos; 00046 00047 static const pos npos; 00048 00049 private: 00050 00051 static const unsigned BHC_MAGIC_SZE; 00052 00053 class Cache; 00054 00055 Cache & _c; 00056 00057 private: 00058 00059 int _cReadMagic(); 00060 00061 protected: 00062 00063 Pathname _cpath; 00064 00065 protected: 00066 00067 std::string _cmagic; 00068 00069 time_t _cdate; 00070 00071 pos _cheaderStart; 00072 00073 protected: 00074 00075 virtual bool magicOk() { return _cmagic.empty(); } 00076 00077 public: 00078 00079 binHeaderCache( const Pathname & cache_r ); 00080 00081 virtual ~binHeaderCache(); 00082 00083 public: 00084 00085 bool open(); 00086 00087 void close(); 00088 00089 bool isOpen() const; 00090 00091 const Pathname & cpath() const { return _cpath; } 00092 00093 const std::string & cmagic() const { return _cmagic; } 00094 00095 time_t cdate() const { return _cdate; } 00096 00097 pos tell() const; 00098 00099 pos seek( const pos pos_r ); 00100 00101 unsigned readData( void * buf_r, unsigned count_r ); 00102 00103 binHeaderPtr readHeader( bool magicp = true ); 00104 }; 00105 00107 00108 #endif // binHeaderCache_h