libzypp  13.10.6
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 Pathname & path () 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

Enumerator
NO_INIT 
INIT 

Definition at line 52 of file WatchFile.h.

Constructor & Destructor Documentation

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

Definition at line 56 of file WatchFile.h.

Member Function Documentation

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

Definition at line 65 of file WatchFile.h.

bool zypp::WatchFile::hasChanged ( )
inline

Definition at line 68 of file WatchFile.h.

Member Data Documentation

Pathname zypp::WatchFile::_path
private

Definition at line 81 of file WatchFile.h.

off_t zypp::WatchFile::_size
private

Definition at line 82 of file WatchFile.h.

time_t zypp::WatchFile::_mtime
private

Definition at line 83 of file WatchFile.h.


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