ewmscp
..
|
represents a watched directory inside a directory tree. More...
Public Member Functions | |
void | buildPath (std::string &path) |
fill path with the fill path to this directory More... | |
void | buildPath (std::string &path, const std::string &aName) |
fill path with the full path to a file in this directory More... | |
std::string | getPath () |
return full path to this dir, for use in error messages only More... | |
watchedDirType (const std::string &aName, int aFd, watchedDirType *aParent=nullptr) | |
construct a new watchedDir. More... | |
~watchedDirType () | |
destruct watchedDir. More... | |
void | invalidateId () |
int | getId () const |
watchedDirType * | getChild (const std::string &aName) |
void | getAdoptedBy (const std::string &newName, watchedDirType *newParent) |
move to a new place in the directory tree. More... | |
Static Public Member Functions | |
static void | dump (std::ostream &out) |
static watchedDirType * | get (int aId) |
get a watcheDir by the inotify id More... | |
static bool | empty () |
test if any directories are watched More... | |
static size_t | size () |
return number of watched directories More... | |
static void | setExtraEventMask (int extraMask) |
Private Member Functions | |
void | becomeChildOfMyParent (watchedDirType *aParent) |
set object a child of the parent. More... | |
Static Private Member Functions | |
static std::map< int, watchedDirType * > & | getWatchedDirs () |
Private Attributes | |
std::string | name |
basename of the directory, i.e. not the full path More... | |
watchedDirType * | parent |
int | fd |
fd for the inotify instance, needed for destructor More... | |
int | id |
the watch id More... | |
std::map< std::string, watchedDirType * > | children |
decltype(getWatchedDirs().begin()) | watchIterator |
iterator in the map that holds this object More... | |
decltype(children.begin()) | childIterator |
iterator in parent's child map that holds this object More... | |
Static Private Attributes | |
static int | extraEventMask = 0 |
represents a watched directory inside a directory tree.
Holds pointers to paren and children in the tree as well as info on the inotify watch.
Definition at line 285 of file inotify_watch.cpp.
|
inline |
construct a new watchedDir.
If it has a parent then name is the basename of the directory, i.e. without path If parent is nullptr then name is the full path to the directory. [in] aFd is the fd to the inotify object. If something goes wrong the id will be -1. Also inserts this directory into the watched directory tree and the id map.
Definition at line 379 of file inotify_watch.cpp.
References throwcall::badval(), becomeChildOfMyParent(), buildPath(), extraEventMask, fd, getWatchedDirs(), parent, and watchIterator.
|
inline |
destruct watchedDir.
Unwatchews it in the inotify_object, removes it from the directory tree (destroig all leftover children, which should be gone now anyway), and unregisters it in the map.
Definition at line 424 of file inotify_watch.cpp.
References childIterator, children, errPrefix, errStream(), fd, getPath(), getWatchedDirs(), throwcall::good0(), parent, and watchIterator.
|
inlineprivate |
set object a child of the parent.
The parent should not have a child of this name, but in extreme stress cases it can have one. In order to continue working we "orphan" that child.
Definition at line 305 of file inotify_watch.cpp.
References childIterator, children, name, and parent.
Referenced by getAdoptedBy(), and watchedDirType().
|
inline |
fill path with the fill path to this directory
Definition at line 333 of file inotify_watch.cpp.
References buildPath(), name, and parent.
Referenced by buildPath(), getPath(), main(), watchDirectory(), and watchedDirType().
|
inline |
fill path with the full path to a file in this directory
Definition at line 342 of file inotify_watch.cpp.
References buildPath().
|
inlinestatic |
Definition at line 321 of file inotify_watch.cpp.
References errPrefix, and getWatchedDirs().
Referenced by main().
|
inlinestatic |
test if any directories are watched
Definition at line 360 of file inotify_watch.cpp.
References getWatchedDirs().
Referenced by main().
|
inlinestatic |
get a watcheDir by the inotify id
Definition at line 356 of file inotify_watch.cpp.
References getWatchedDirs().
Referenced by main().
|
inline |
move to a new place in the directory tree.
This is needed when a directory is moved (renamed) and changes the tree as well as the name of this directory.
Definition at line 467 of file inotify_watch.cpp.
References becomeChildOfMyParent(), childIterator, children, name, and parent.
Referenced by main().
|
inline |
|
inline |
|
inline |
return full path to this dir, for use in error messages only
Definition at line 349 of file inotify_watch.cpp.
References buildPath().
Referenced by ~watchedDirType().
|
inlinestaticprivate |
Definition at line 286 of file inotify_watch.cpp.
Referenced by dump(), empty(), get(), size(), watchedDirType(), and ~watchedDirType().
|
inline |
Definition at line 448 of file inotify_watch.cpp.
|
inlinestatic |
Definition at line 368 of file inotify_watch.cpp.
References extraEventMask.
Referenced by main().
|
inlinestatic |
return number of watched directories
Definition at line 364 of file inotify_watch.cpp.
References getWatchedDirs().
Referenced by main().
|
private |
iterator in parent's child map that holds this object
Definition at line 298 of file inotify_watch.cpp.
Referenced by becomeChildOfMyParent(), getAdoptedBy(), and ~watchedDirType().
|
private |
Definition at line 296 of file inotify_watch.cpp.
Referenced by becomeChildOfMyParent(), getAdoptedBy(), getChild(), and ~watchedDirType().
|
staticprivate |
Definition at line 290 of file inotify_watch.cpp.
Referenced by setExtraEventMask(), and watchedDirType().
|
private |
fd for the inotify instance, needed for destructor
Definition at line 294 of file inotify_watch.cpp.
Referenced by watchedDirType(), and ~watchedDirType().
|
private |
|
private |
basename of the directory, i.e. not the full path
Definition at line 292 of file inotify_watch.cpp.
Referenced by becomeChildOfMyParent(), buildPath(), and getAdoptedBy().
|
private |
Definition at line 293 of file inotify_watch.cpp.
Referenced by becomeChildOfMyParent(), buildPath(), getAdoptedBy(), watchedDirType(), and ~watchedDirType().
|
private |
iterator in the map that holds this object
Definition at line 297 of file inotify_watch.cpp.
Referenced by watchedDirType(), and ~watchedDirType().