libzypp 17.37.10

zypp::WatchFile Class Reference

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

`#include <zypp-core/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 Pathname & | path () 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",
WatchFile::NO_INIT );
if ( sysconfigFile.hasChanged() )
{
// reload the file...
}
zypp::WatchFile::WatchFile
WatchFile(const Pathname &path_r=Pathname(), Initial mode=INIT)
Definition watchfile.h:56
zypp::WatchFile::NO_INIT
@ NO_INIT
Definition watchfile.h:52

Definition at line 49 of file watchfile.h.

## Member Enumeration Documentation

## ◆ Initial

enum zypp::WatchFile::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 | ) |
| inline private

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:

- zypp-core/fs/watchfile.h