#include <inotify-cxx.h>
Public Member Functions | |
InotifyWatch (const std::string &rPath, int32_t uMask, bool fEnabled=true) | |
Constructor. | |
~InotifyWatch () | |
Destructor. | |
int32_t | GetDescriptor () const |
Returns the watch descriptor. | |
const std::string & | GetPath () const |
Returns the watched file path. | |
uint32_t | GetMask () const |
Returns the watch event mask. | |
void | SetMask (uint32_t uMask) throw (InotifyException) |
Sets the watch event mask. | |
Inotify * | GetInotify () |
Returns the appropriate inotify class instance. | |
void | SetEnabled (bool fEnabled) throw (InotifyException) |
Enables/disables the watch. | |
bool | IsEnabled () const |
Checks whether the watch is enabled. | |
bool | IsRecursive () const |
Checks whether the watch is recursive. | |
Private Member Functions | |
IN_LOCK_DECL void | __Disable () |
Disables the watch (due to removing by the kernel). | |
Private Attributes | |
std::string | m_path |
watched file path | |
uint32_t | m_uMask |
event mask | |
int32_t | m_wd |
watch descriptor | |
Inotify * | m_pInotify |
inotify object | |
bool | m_fEnabled |
events enabled yes/no | |
Friends | |
class | Inotify |
It holds information about the inotify watch on a particular inode.
If the INOTIFY_THREAD_SAFE is defined this class is thread-safe.
InotifyWatch::InotifyWatch | ( | const std::string & | rPath, | |
int32_t | uMask, | |||
bool | fEnabled = true | |||
) | [inline] |
Constructor.
Creates an inotify watch. Because this watch is inactive it has an invalid descriptor (-1).
[in] | rPath | watched file path |
[in] | uMask | mask for events |
[in] | fEnabled | events enabled yes/no |
InotifyWatch::~InotifyWatch | ( | ) | [inline] |
Destructor.
void InotifyWatch::__Disable | ( | ) | [private] |
Disables the watch (due to removing by the kernel).
This method must be called after receiving an event. It ensures the watch object is consistent with the kernel data.
int32_t InotifyWatch::GetDescriptor | ( | ) | const [inline] |
Returns the watch descriptor.
Inotify* InotifyWatch::GetInotify | ( | ) | [inline] |
Returns the appropriate inotify class instance.
uint32_t InotifyWatch::GetMask | ( | ) | const [inline] |
Returns the watch event mask.
const std::string& InotifyWatch::GetPath | ( | ) | const [inline] |
Returns the watched file path.
bool InotifyWatch::IsEnabled | ( | ) | const [inline] |
Checks whether the watch is enabled.
bool InotifyWatch::IsRecursive | ( | ) | const [inline] |
Checks whether the watch is recursive.
A recursive watch monitors a directory itself and all its subdirectories. This watch is a logical object which may have many underlying kernel watches.
void InotifyWatch::SetEnabled | ( | bool | fEnabled | ) | throw (InotifyException) |
Enables/disables the watch.
If the watch is active (added to an instance of Inotify) this method may fail due to unsuccessful re-setting the watch in the kernel.
Re-setting the current state has no effect.
[in] | fEnabled | set enabled yes/no |
InotifyException | thrown if enabling/disabling fails |
void InotifyWatch::SetMask | ( | uint32_t | uMask | ) | throw (InotifyException) |
Sets the watch event mask.
If the watch is active (added to an instance of Inotify) this method may fail due to unsuccessful re-setting the watch in the kernel.
[in] | uMask | event mask |
InotifyException | thrown if changing fails |
friend class Inotify [friend] |
bool InotifyWatch::m_fEnabled [private] |
events enabled yes/no
std::string InotifyWatch::m_path [private] |
watched file path
Inotify* InotifyWatch::m_pInotify [private] |
inotify object
uint32_t InotifyWatch::m_uMask [private] |
event mask
int32_t InotifyWatch::m_wd [private] |
watch descriptor