32 void recursiveTimestamp(
const Pathname & dir_r, time_t & max_r )
34 std::list<std::string> dircontent;
38 for_( it, dircontent.begin(), dircontent.end() )
43 if ( pi.mtime() > max_r )
45 recursiveTimestamp( pi.path(), max_r );
71 if ( !checksum_r.empty() ) {
72 static const std::string magic(
"43" );
80 void inject( std::string && checksum_r,
Date && timestamp_r )
82 if ( !checksum_r.empty() ) {
119 std::stringstream ss;
139 std::ifstream file( path_r.
c_str() );
141 WAR <<
"No cookie file " << path_r << endl;
148 Date stmp { useMtime_r ?
PathInfo( path_r ).
mtime() : str::strtonum<time_t>( time ) };
149 inject( std::move(line), std::move(stmp) );
159 friend Impl * rwcowClone<Impl>(
const Impl * rhs );
162 {
return new Impl( *
this ); }
173 : _pimpl( new
Impl() )
177 : _pimpl( new
Impl() )
186 else if ( info.
isDir() )
188 time_t t = info.
mtime();
189 recursiveTimestamp( path_r, t );
196 : _pimpl( new
Impl() )
202 : _pimpl( new
Impl() )
226 std::ofstream file(path_r.
c_str());
251 {
return lhs.
_pimpl->checksum() == rhs.
_pimpl->checksum(); }
std::set< std::string > Checksums
bool empty() const
Whether the status is empty (empty checksum)
std::string getline(std::istream &str, const Trim trim_r)
Return stream content up to (but not returning) the next newline.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
std::string sha1sum(const Pathname &file)
Compute a files sha1sum.
void injectFrom(const Impl &rhs)
Inject the raw data from rhs.
std::string checksum() const
void inject(std::string &&checksum_r, Date &×tamp_r)
Inject raw data (no magic added).
std::ostream & dumpOn(std::ostream &str) const
Dump to log file (not to/from CookieFile).
void assignFromCookieFile(const Pathname &path_r, bool useMtime_r=false)
#define for_(IT, BEG, END)
Convenient for-loops using iterator.
const char * c_str() const
String representation.
String related utilities and Regular expression matching.
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
What is known about a repository.
bool operator==(const SetRelation::Enum &lhs, const SetCompare &rhs)
RepoStatus()
Default ctor.
static RepoStatus fromCookieFile(const Pathname &path)
Reads the status from a cookie file.
Url url() const
Pars pro toto: The first repository url.
void saveToCookieFile(const Pathname &path_r) const
Save the status information to a cookie file.
Store and operate on date (time_t).
std::string asString() const
Returns a default string representation of the Url object.
static RepoStatus fromCookieFileUseMtime(const Pathname &path)
Reads the status from a cookie file but uses the files mtime.
void assignFromCtor(std::string &&checksum_r, Date &×tamp_r)
Assign data called from RepoStatus ctor (adds magic).
const std::string & asString() const
String representation.
bool isExist() const
Return whether valid stat info exists.
std::string stripLastWord(std::string &line, const bool rtrim_first)
int readdir(std::list< std::string > &retlist_r, const Pathname &path_r, bool dots_r)
Return content of directory via retlist.
std::string numstring(char n, int w=0)
std::optional< std::string > _cachedchecksum
RepoStatus implementation.
Base class for Exception.
Date timestamp() const
The time the data were changed the last time.
std::string checksum(const Pathname &file, const std::string &algorithm)
Compute a files checksum.
RWCOW_pointer< Impl > _pimpl
Implementation.
Impl * clone() const
clone for RWCOW_pointer
Wrapper class for ::stat/::lstat.
static CheckSum sha1(const std::string &checksum)
Track changing files or directories.
RepoStatus operator &&(const RepoStatus &lhs, const RepoStatus &rhs)
std::string checksum() const
Easy-to use interface to the ZYPP dependency resolver.
static CheckSum sha1FromString(const std::string &input_r)