libzypp  17.1.1
zypp::WatchFile Class Reference

Remember a files attributes to detect content changes. More...

#include <WatchFile.h>

Public Types

enum  Initial { NO_INIT, INIT }

Public Member Functions

 WatchFile (const Pathname &path_r=Pathname(), Initial mode=INIT)
const Pathnamepath () const
off_t lastSize () const
time_t lastMtime () const
bool isDirty () const
bool hasChanged ()

Private Attributes

Pathname _path
off_t _size
time_t _mtime

Detailed Description

Remember a files attributes to detect content changes.

Repeatedly call hasChanged to check whether the content has changed since the last call. Creation or deletion of the file will be reported as change as well.

Per default the ctor stats the file, so hasChanged will detect changes done after WatchFile was created.

You may omit the initial stat by passing NO_INIT as second argument to the ctor. WatchFile will behave as if the file did not exist at the time WatchFile was created.

static WatchFile sysconfigFile( "/etc/sysconfig/SuSEfirewall2",
if ( sysconfigFile.hasChanged() )
// reload the file...

Definition at line 49 of file WatchFile.h.

Member Enumeration Documentation

◆ Initial


Definition at line 52 of file WatchFile.h.

Constructor & Destructor Documentation

◆ WatchFile()

zypp::WatchFile::WatchFile ( const Pathname path_r = Pathname(),
Initial  mode = INIT 

Definition at line 56 of file WatchFile.h.

Member Function Documentation

◆ path()

const Pathname& zypp::WatchFile::path ( ) const

Definition at line 65 of file WatchFile.h.

◆ lastSize()

off_t zypp::WatchFile::lastSize ( ) const

Definition at line 68 of file WatchFile.h.

◆ lastMtime()

time_t zypp::WatchFile::lastMtime ( ) const

Definition at line 71 of file WatchFile.h.

◆ isDirty()

bool zypp::WatchFile::isDirty ( ) const

Definition at line 74 of file WatchFile.h.

◆ hasChanged()

bool zypp::WatchFile::hasChanged ( )

Definition at line 80 of file WatchFile.h.

Member Data Documentation

◆ _path

Pathname zypp::WatchFile::_path

Definition at line 93 of file WatchFile.h.

◆ _size

off_t zypp::WatchFile::_size

Definition at line 94 of file WatchFile.h.

◆ _mtime

time_t zypp::WatchFile::_mtime

Definition at line 95 of file WatchFile.h.

The documentation for this class was generated from the following file: