Checking for changes to files. More...
#include <fileMonitor.H>

Public Types | |
| enum | fileState { UNMODIFIED = 0 , MODIFIED = 1 , DELETED = 2 } |
| Enumeration defining the file state. More... | |
Public Member Functions | |
| fileMonitor (const bool useInotify) | |
| Construct with specified inotify use. | |
| ~fileMonitor () | |
| Destructor. | |
| label | addWatch (const fileName &) |
| Add file to watch. Return watch descriptor. | |
| bool | removeWatch (const label watchFd) |
| Remove file to watch. Return true if successful. | |
| const fileName & | getFile (const label watchFd) const |
| Get name of file being watched. | |
| fileState | getState (const label watchFd) const |
| Check state using handle. | |
| void | updateStates (const bool masterOnly, const bool syncPar) const |
| Check state of all files. Updates state_. | |
| void | setUnmodified (const label watchFd) |
| Reset state (e.g. after having read it) using handle. | |
Static Public Attributes | |
| static const Enum< fileState > | fileStateNames_ |
| static int | debug |
| Named/registered debug switch: 'fileMonitor'. | |
Checking for changes to files.
Compile with FOAM_USE_INOTIFY to use the inotify (Linux specific, since 2.6.13) framework. The problem is that inotify does not work on nfs3 mounted directories!!
Definition at line 61 of file fileMonitor.H.
| enum fileState |
Enumeration defining the file state.
| Enumerator | |
|---|---|
| UNMODIFIED | |
| MODIFIED | |
| DELETED | |
Definition at line 70 of file fileMonitor.H.
|
explicit |
Construct with specified inotify use.
Definition at line 440 of file fileMonitor.C.
| ~fileMonitor | ( | ) |
Destructor.
Definition at line 453 of file fileMonitor.C.
| Foam::label addWatch | ( | const fileName & | fName | ) |
Add file to watch. Return watch descriptor.
Definition at line 461 of file fileMonitor.C.
References debug, Foam::endl(), Foam::Pout, UNMODIFIED, and WarningInFunction.

| bool removeWatch | ( | const label | watchFd | ) |
Remove file to watch. Return true if successful.
Definition at line 499 of file fileMonitor.C.
References debug, Foam::endl(), and Foam::Pout.

| const Foam::fileName & getFile | ( | const label | watchFd | ) | const |
Get name of file being watched.
Definition at line 513 of file fileMonitor.C.
| Foam::fileMonitor::fileState getState | ( | const label | watchFd | ) | const |
Check state using handle.
Definition at line 519 of file fileMonitor.C.
| void updateStates | ( | const bool | masterOnly, |
| const bool | syncPar ) const |
Check state of all files. Updates state_.
Definition at line 526 of file fileMonitor.C.
References UPstream::broadcast, debug, Foam::endl(), forAll, Pstream::listCombineGather(), UPstream::master(), MODIFIED, Foam::Pout, Foam::reduce(), PackedList< Width >::set(), UList< T >::size(), PackedList< Width >::storage(), and WarningInFunction.

| void setUnmodified | ( | const label | watchFd | ) |
Reset state (e.g. after having read it) using handle.
Definition at line 623 of file fileMonitor.C.
References Foam::highResLastModified(), and UNMODIFIED.

|
static |
Definition at line 77 of file fileMonitor.H.
|
static |
Named/registered debug switch: 'fileMonitor'.
Definition at line 137 of file fileMonitor.H.
Referenced by addWatch(), removeWatch(), and updateStates().