The Node Monitor is a service that lets you ask to be notified of certain file system changes
The Node Monitor is a service that lets you ask to be notified of certain file system changes. You can ask to be told when a change is made to...The hook functions in this class are by default implemented to do nothing. The lone exception is NodeMonitor::EntryDeleted, which is implemented to simply turn off monitoring for the node since it is now deleted from the files system.
- The contents of a specific directory.
- The name of a specific entry.
- Any stat field of a specific entry.
- Any attribute of a specific entry.
Hook functions must not block. Learn to use inter-thread communication and semaphores. It's easy.
Remember that BStatable is the ancestor to both BNode and BEntry (which is, in turn, the ancestor of BFile, BDirectory, and BSymLink. If you have an entry_ref, reassure yourself that it is not abstract (BEntry::Exists), and then you can turn it into a BStatable derivative. If you are working from a BNode only, ensure that it's properly initialized by calling InitCheck() before building a NodeMonitor on it.
Keep in mind that the reference may or may not be abstract. That's up to you
to find out.
First, the reference may come out invalid. This would be the case if the directory
node given has been unlinked from the directory it is in.
Second the reference may come out abstract. That is, refer to a file that does not
exist in a directory that does. That's up to you
to find out, perhaps by locking the directory node and testing the entry
you just created with BEntry::Exists.
In various node monitor hook functions, a parameter is passed in that is a
node_ref to a directory. For subtle reasons in the storage kit, you are allowed
to turn a directory node_ref into its corresponding entry.
Note that the directory object may not be valid if the directory that
contains the node_ref has not been locked. You should test
it (with BDirectory::InitCheck) to make sure.
For files, this can be overcome by maintaining BFile objects that point to nodes you
want to keep around. Refer to the Storage Kit's documentation on the node
monitor system for an example.
Note: It is a valid operation to
Recall that few parts of stat can change:
virtual ~NodeMonitor()
File system utility functions
static entry_ref GetEntryRef(node_ref &from_directory, const char *name)
static BEntry GetEntry(node_ref &from_directory, const char *name)
BDirectory directory;
BEntry entry;
directory = GetDirectory(dir_node_ref);
if (directory.InitCheck() == B_NO_ERROR) {
directory.Lock();
BEntry entry = GetEntry(dir_node_ref, name)));
if (entry.Exists()) {
...
}
directory.Unlock();
}
name - The name of the directory to refer to in the directory node.
static BDirectory GetDirectory(node_ref &directory_ref)
status_t InitCheck()
virtual void EntryDeleted(node_ref &fromDirectory)
delete this
from this hook
function, once you've dealt with the disappearance of this node. This is,
in fact, the default behaviour.
virtual void EntryMoved(node_ref &from_directory, node_ref &to_directory, const char *newName)
virtual void StatChanged()
virtual void AttributeChanged(const char *which)
node_ref mTargetEntry
const BStatable* mWatched
alphabetic index hierarchy of classes
this page has been generated automatically by doc++
(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de