1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/RepoStatus.h
12 #ifndef ZYPP2_REPOSTATUS_H
13 #define ZYPP2_REPOSTATUS_H
16 #include "zypp/base/PtrTypes.h"
17 #include "zypp/CheckSum.h"
18 #include "zypp/Date.h"
20 ///////////////////////////////////////////////////////////////////
22 { /////////////////////////////////////////////////////////////////
24 ///////////////////////////////////////////////////////////////////
26 /// \brief Track changing files or directories.
28 /// Compute timestamp and checksum for individual files or
29 /// directories (recursively) to track changing content.
31 /// The timestamp most probably denotes the time the data were
32 /// changed the last time, that's why it is exposed.
34 /// The checksum however is an implementation detail and of no
35 /// use outside this class. \ref operator== tells if the checksums
36 /// of two rRepoStatus are the same.
37 ///////////////////////////////////////////////////////////////////
40 friend std::ostream & operator<<( std::ostream & str, const RepoStatus & obj );
41 friend RepoStatus operator&&( const RepoStatus & lhs, const RepoStatus & rhs );
42 friend bool operator==( const RepoStatus & lhs, const RepoStatus & rhs );
48 /** Compute status for single file or directory (recursively)
50 * \note Construction from a non existing file will result
53 explicit RepoStatus( const Pathname & path_r );
59 /** Reads the status from a cookie file
60 * \returns An empty \ref RepoStatus if the file does not
61 * exist or is not readable.
62 * \see \ref saveToCookieFile
64 static RepoStatus fromCookieFile( const Pathname & path );
66 /** Save the status information to a cookie file
67 * \throws Exception if the file can't be saved
68 * \see \ref fromCookieFile
70 void saveToCookieFile( const Pathname & path_r ) const;
73 /** Whether the status is empty (default constucted) */
76 /** The time the data were changed the last time */
77 Date timestamp() const;
80 struct Impl; ///< Implementation
82 RWCOW_pointer<Impl> _pimpl; ///< Pointer to implementation
84 ///////////////////////////////////////////////////////////////////
86 /** \relates RepoStatus Stream output */
87 std::ostream & operator<<( std::ostream & str, const RepoStatus & obj );
89 /** \relates RepoStatus Combine two RepoStatus (combined checksum and newest timestamp) */
90 RepoStatus operator&&( const RepoStatus & lhs, const RepoStatus & rhs );
92 /** \relates RepoStatus Whether 2 RepoStatus refer to the same content checksum */
93 bool operator==( const RepoStatus & lhs, const RepoStatus & rhs );
95 /** \relates RepoStatus Whether 2 RepoStatus refer to different content checksums */
96 inline bool operator!=( const RepoStatus & lhs, const RepoStatus & rhs )
97 { return ! ( lhs == rhs ); }
99 /////////////////////////////////////////////////////////////////
101 ///////////////////////////////////////////////////////////////////
102 #endif // ZYPP2_REPOSTATUS_H