libzypp 17.31.23
zypp::WatchFile Class Reference

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

#include <fs/watchfile.h>

Public Types

enum  Initial { NO_INIT , INIT }
 

Public Member Functions

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

Private Member Functions

void ctorInit (Initial mode)
 

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...
}
Remember a files attributes to detect content changes.
Definition: watchfile.h:50

Definition at line 49 of file watchfile.h.

Member Enumeration Documentation

◆ Initial

Enumerator
NO_INIT 
INIT 

Definition at line 52 of file watchfile.h.

Constructor & Destructor Documentation

◆ WatchFile() [1/2]

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

Definition at line 56 of file watchfile.h.

◆ WatchFile() [2/2]

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

Definition at line 61 of file watchfile.h.

Member Function Documentation

◆ path()

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

Definition at line 65 of file watchfile.h.

◆ lastSize()

off_t zypp::WatchFile::lastSize ( ) const
inline

Definition at line 68 of file watchfile.h.

◆ lastMtime()

time_t zypp::WatchFile::lastMtime ( ) const
inline

Definition at line 71 of file watchfile.h.

◆ isDirty()

bool zypp::WatchFile::isDirty ( ) const
inline

Definition at line 74 of file watchfile.h.

◆ hasChanged()

bool zypp::WatchFile::hasChanged ( )
inline

Definition at line 80 of file watchfile.h.

◆ ctorInit()

void zypp::WatchFile::ctorInit ( Initial  mode)
inlineprivate

Definition at line 93 of file watchfile.h.

Member Data Documentation

◆ _path

Pathname zypp::WatchFile::_path
private

Definition at line 101 of file watchfile.h.

◆ _size

off_t zypp::WatchFile::_size
private

Definition at line 102 of file watchfile.h.

◆ _mtime

time_t zypp::WatchFile::_mtime
private

Definition at line 103 of file watchfile.h.


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