Pyro higlevel API
Classes | Public Member Functions | List of all members
os::NodeMonitor Class Reference

Filesystem node monitor. More...

Classes

class  Private
 

Public Member Functions

 NodeMonitor ()
 
 NodeMonitor (const String &cPath, uint32 nFlags, const Handler *pcHandler, const Looper *pcLooper=NULL)
 
 NodeMonitor (const String &cPath, uint32 nFlags, const Messenger &cTarget)
 
 NodeMonitor (const Directory &cDir, const String &cPath, uint32 nFlags, const Handler *pcHandler, const Looper *pcLooper=NULL)
 
 NodeMonitor (const Directory &cDir, const String &cPath, uint32 nFlags, const Messenger &cTarget)
 
 NodeMonitor (const FileReference &cRef, uint32 nFlags, const Handler *pcHandler, const Looper *pcLooper=NULL)
 
 NodeMonitor (const FileReference &cRef, uint32 nFlags, const Messenger &cTarget)
 
 NodeMonitor (const FSNode *pcNode, uint32 nFlags, const Handler *pcHandler, const Looper *pcLooper=NULL)
 
 NodeMonitor (const FSNode *pcNode, uint32 nFlags, const Messenger &cTarget)
 
 ~NodeMonitor ()
 
bool IsValid () const
 
status_t Unset ()
 
status_t SetTo (const String &cPath, uint32 nFlags, const Handler *pcHandler, const Looper *pcLooper=NULL)
 
status_t SetTo (const String &cPath, uint32 nFlags, const Messenger &cTarget)
 
status_t SetTo (const Directory &cDir, const String &cPath, uint32 nFlags, const Handler *pcHandler, const Looper *pcLooper=NULL)
 
status_t SetTo (const Directory &cDir, const String &cPath, uint32 nFlags, const Messenger &cTarget)
 
status_t SetTo (const FileReference &cRef, uint32 nFlags, const Handler *pcHandler, const Looper *pcLooper=NULL)
 
status_t SetTo (const FileReference &cRef, uint32 nFlags, const Messenger &cTarget)
 
status_t SetTo (const FSNode *pcNode, uint32 nFlags, const Handler *pcHandler, const Looper *pcLooper=NULL)
 
status_t SetTo (const FSNode *pcNode, uint32 nFlags, const Messenger &cTarget)
 
int GetMonitor () const
 

Detailed Description

Description:
The node monitor allow you to monitor changes done in the filesystem. This is very useful for the desktop manager, file requesters and other things that display the content of a directory to the user since it makes it possible to keep the directory list in sync with the actual directory without any need for polling. It might also be useful for other purposes like a daemon who want to monitor it's config file and reload it whenever it has changed.

You can monitor file creations and deletions as well as file renaming inside a directory. You can also monitor a file or directory for changes to the attributes or stat info (size, time-stamps, etc etc).

A node monitor will produce asyncronous events that will be sendt to a os::Looper whenever a relevant change is made to the node it is monitoring. When creating a NodeMonitor you must provide a bit-mask telling what event's you are interrested in and what os::Looper/os::Handler should receive the event message.

Here is a list of the flags controlling what to monitor:

When a relevant change happens to the filesystem one of the following messages are sendt to the target of the monitor:

All messages contain at least 3 elements:

Field Type Description
"event" T_INT32 One of the NWEVENT_* event codes
"device" T_INT32 The dev_t device number of the FS containing the affected node(s)
"node" T_INT64 The ino_t i-node number of the affected node

NWEVENT_CREATED

Sendt when a file is created in a directory watched with NWATCH_DIR.

Field Type Description
"event" T_INT32 NWEVENT_CREATED
"device" T_INT32 The dev_t device number of the FS where the file was created.
"node" T_INT64 The ino_t i-node number of the new node
"dir_node" T_INT64 The ino_t of the directory where the node was created.
"name" T_STRING The name of the new node

NWEVENT_DELETED

Sendt when a file watched with NWATCH_NAME or that lives in a directory watched with NWATCH_DIR is deleted.

Field Type Description
"event" T_INT32 NWEVENT_DELETED
"device" T_INT32 The dev_t device number of the FS where the file was deleted.
"node" T_INT64 The ino_t i-node number of the node that was deleted.
"dir_node" T_INT64 The ino_t of the directory from where the node was deleted.
"name" T_STRING The name of the deleted node

NWEVENT_MOVED

Sendt when a file watched with NWATCH_NAME or that lives in a directory watched with NWATCH_DIR is deleted.

Field Type Description
"event" T_INT32 NWEVENT_MOVED
"device" T_INT32 The dev_t device number of the FS containing the moved/renamed file.
"node" T_INT64 The ino_t i-node number of the node that was moved/renamed.
"old_dir" T_INT64 The ino_t i-node number of the directory the file was moved from.
"new_dir" T_INT64 The ino_t i-node number of the directory the file was moved to. If this is the same as "old_dir" the file was only renamed and not moved.
"name" T_STRING The new file name.
"old_path" T_STRING Only present if the NWATCH_FULL_DST_PATH was set and the file was moved into a directory watched with NWATCH_DIR. The string contain the full path of the directory the file was moved from.
"new_path" T_STRING Only present if the NWATCH_FULL_DST_PATH was set and the file was moved out of a directory watched with NWATCH_DIR or the moved/renamed file itself was watched with NWATCH_NAME (and NWATCH_FULL_DST_PATH)
See Also
os::Looper, os::Handler, os::FSNode
Author
Kurt Skauen (kurt@.nosp@m.athe.nosp@m.os.cx)

Constructor & Destructor Documentation

NodeMonitor::NodeMonitor ( )
NodeMonitor::NodeMonitor ( const String cPath,
uint32  nFlags,
const Handler pcHandler,
const Looper pcLooper = NULL 
)
NodeMonitor::NodeMonitor ( const String cPath,
uint32  nFlags,
const Messenger cTarget 
)
NodeMonitor::NodeMonitor ( const Directory cDir,
const String cPath,
uint32  nFlags,
const Handler pcHandler,
const Looper pcLooper = NULL 
)
NodeMonitor::NodeMonitor ( const Directory cDir,
const String cPath,
uint32  nFlags,
const Messenger cTarget 
)
NodeMonitor::NodeMonitor ( const FileReference cRef,
uint32  nFlags,
const Handler pcHandler,
const Looper pcLooper = NULL 
)
NodeMonitor::NodeMonitor ( const FileReference cRef,
uint32  nFlags,
const Messenger cTarget 
)
NodeMonitor::NodeMonitor ( const FSNode pcNode,
uint32  nFlags,
const Handler pcHandler,
const Looper pcLooper = NULL 
)
NodeMonitor::NodeMonitor ( const FSNode pcNode,
uint32  nFlags,
const Messenger cTarget 
)
NodeMonitor::~NodeMonitor ( )

Member Function Documentation

int NodeMonitor::GetMonitor ( ) const
bool os::NodeMonitor::IsValid ( ) const
status_t NodeMonitor::SetTo ( const String cPath,
uint32  nFlags,
const Handler pcHandler,
const Looper pcLooper = NULL 
)
status_t NodeMonitor::SetTo ( const String cPath,
uint32  nFlags,
const Messenger cTarget 
)
status_t NodeMonitor::SetTo ( const Directory cDir,
const String cPath,
uint32  nFlags,
const Handler pcHandler,
const Looper pcLooper = NULL 
)

References SetTo().

status_t NodeMonitor::SetTo ( const Directory cDir,
const String cPath,
uint32  nFlags,
const Messenger cTarget 
)
status_t NodeMonitor::SetTo ( const FileReference cRef,
uint32  nFlags,
const Handler pcHandler,
const Looper pcLooper = NULL 
)

References SetTo().

status_t NodeMonitor::SetTo ( const FileReference cRef,
uint32  nFlags,
const Messenger cTarget 
)
status_t NodeMonitor::SetTo ( const FSNode pcNode,
uint32  nFlags,
const Handler pcHandler,
const Looper pcLooper = NULL 
)

References SetTo().

status_t NodeMonitor::SetTo ( const FSNode pcNode,
uint32  nFlags,
const Messenger cTarget 
)
status_t NodeMonitor::Unset ( )