btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / private / storage / PathMonitor.h
blob2a511ec40cd954988f84fc221f1c9aaf1e2b6d25
1 /*
2 * Copyright 2007-2013, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef _PATH_MONITOR_H
6 #define _PATH_MONITOR_H
9 #include <NodeMonitor.h>
12 // Monitoring a path always implies B_WATCH_NAME for the path itself. I.e. even
13 // if only B_WATCH_STAT is specified, B_ENTRY_{CREATED,MOVED,REMOVED}
14 // notifications are sent when the respective entry is created/moved/removed.
16 // additional flags (combined with those in NodeMonitor.h)
17 #define B_WATCH_RECURSIVELY 0x0100
18 // Watch not only the entry specified by the path, but also recursively all
19 // descendents. A recursive B_WATCH_DIRECTORY is implied, i.e.
20 // B_ENTRY_{CREATED,MOVED,REMOVED} notifications will be sent for any entry
21 // change below the given path, unless explicitly suppressed by
22 // B_WATCH_{FILES,DIRECTORIES}_ONLY.
23 #define B_WATCH_FILES_ONLY 0x0200
24 // A notification will only be sent when the node it concerns is not a
25 // directory. No effect in non-recursive mode.
26 #define B_WATCH_DIRECTORIES_ONLY 0x0400
27 // A notification will only be sent when the node it concerns is a
28 // directory. No effect in non-recursive mode.
30 #define B_PATH_MONITOR '_PMN'
33 namespace BPrivate {
36 class BPathMonitor {
37 public:
38 class BWatchingInterface;
40 public:
41 static status_t StartWatching(const char* path, uint32 flags,
42 const BMessenger& target);
44 static status_t StopWatching(const char* path,
45 const BMessenger& target);
46 static status_t StopWatching(const BMessenger& target);
48 static void SetWatchingInterface(
49 BWatchingInterface* watchingInterface);
50 // pass NULL to reset to default
52 private:
53 BPathMonitor();
54 ~BPathMonitor();
56 static status_t _InitIfNeeded();
57 static void _Init();
61 /*! Base class just delegates to the respective C functions.
63 class BPathMonitor::BWatchingInterface {
64 public:
65 BWatchingInterface();
66 virtual ~BWatchingInterface();
68 virtual status_t WatchNode(const node_ref* node, uint32 flags,
69 const BMessenger& target);
70 virtual status_t WatchNode(const node_ref* node, uint32 flags,
71 const BHandler* handler,
72 const BLooper* looper = NULL);
74 virtual status_t StopWatching(const BMessenger& target);
75 virtual status_t StopWatching(const BHandler* handler,
76 const BLooper* looper = NULL);
80 } // namespace BPrivate
83 using BPrivate::BPathMonitor;
86 #endif // _PATH_MONITOR_H