2007-05-04 16:02:04 +00:00
|
|
|
/*
|
2013-06-20 13:59:22 +02:00
|
|
|
* Copyright 2007-2013, Haiku Inc. All Rights Reserved.
|
2007-05-04 16:02:04 +00:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _PATH_MONITOR_H
|
|
|
|
#define _PATH_MONITOR_H
|
|
|
|
|
|
|
|
|
|
|
|
#include <NodeMonitor.h>
|
|
|
|
|
|
|
|
|
|
|
|
// additional flags (combined with those in NodeMonitor.h)
|
2013-06-23 13:01:09 +02:00
|
|
|
#define B_WATCH_FILES_ONLY 0x0100
|
|
|
|
#define B_WATCH_RECURSIVELY 0x0200
|
|
|
|
#define B_WATCH_DIRECTORIES_ONLY 0x0400
|
2008-08-11 20:02:59 +00:00
|
|
|
// NOTE: B_WATCH_RECURSIVELY usually implies to watch for file changes as well,
|
|
|
|
// if that is not desired, add B_WATCH_FOLDERS_ONLY to the flags.
|
2007-05-04 16:02:04 +00:00
|
|
|
|
|
|
|
#define B_PATH_MONITOR '_PMN'
|
|
|
|
|
2013-06-20 13:59:22 +02:00
|
|
|
|
2007-05-04 16:02:04 +00:00
|
|
|
namespace BPrivate {
|
|
|
|
|
2013-06-20 13:59:22 +02:00
|
|
|
|
2007-05-04 16:02:04 +00:00
|
|
|
class BPathMonitor {
|
2013-06-20 13:59:22 +02:00
|
|
|
public:
|
|
|
|
class BWatchingInterface;
|
|
|
|
|
2008-08-04 13:04:45 +00:00
|
|
|
public:
|
|
|
|
static status_t StartWatching(const char* path, uint32 flags,
|
2008-08-11 20:02:59 +00:00
|
|
|
BMessenger target);
|
2007-05-04 16:02:04 +00:00
|
|
|
|
2008-08-04 13:04:45 +00:00
|
|
|
static status_t StopWatching(const char* path,
|
|
|
|
BMessenger target);
|
|
|
|
static status_t StopWatching(BMessenger target);
|
2007-05-04 16:02:04 +00:00
|
|
|
|
2013-06-20 13:59:22 +02:00
|
|
|
static void SetWatchingInterface(
|
|
|
|
BWatchingInterface* watchingInterface);
|
|
|
|
// pass NULL to reset to default
|
|
|
|
|
2008-08-04 13:04:45 +00:00
|
|
|
private:
|
|
|
|
BPathMonitor();
|
|
|
|
~BPathMonitor();
|
2007-05-08 00:30:59 +00:00
|
|
|
|
2013-06-20 13:48:21 +02:00
|
|
|
static status_t _InitIfNeeded();
|
|
|
|
static void _Init();
|
2007-05-04 16:02:04 +00:00
|
|
|
};
|
|
|
|
|
2013-06-20 13:59:22 +02:00
|
|
|
|
|
|
|
/*! Base class just delegates to the respective C functions.
|
|
|
|
*/
|
|
|
|
class BPathMonitor::BWatchingInterface {
|
|
|
|
public:
|
|
|
|
BWatchingInterface();
|
|
|
|
virtual ~BWatchingInterface();
|
|
|
|
|
|
|
|
virtual status_t WatchNode(const node_ref* node, uint32 flags,
|
|
|
|
const BMessenger& target);
|
|
|
|
virtual status_t WatchNode(const node_ref* node, uint32 flags,
|
|
|
|
const BHandler* handler,
|
|
|
|
const BLooper* looper = NULL);
|
|
|
|
|
|
|
|
virtual status_t StopWatching(const BMessenger& target);
|
|
|
|
virtual status_t StopWatching(const BHandler* handler,
|
|
|
|
const BLooper* looper = NULL);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-05-04 16:02:04 +00:00
|
|
|
} // namespace BPrivate
|
|
|
|
|
2013-06-20 13:59:22 +02:00
|
|
|
|
2007-05-04 16:02:04 +00:00
|
|
|
#endif // _PATH_MONITOR_H
|