haiku/headers/private/storage/PathMonitor.h
2013-06-27 21:57:42 +02:00

73 lines
1.8 KiB
C++

/*
* Copyright 2007-2013, Haiku Inc. All Rights Reserved.
* 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)
#define B_WATCH_FILES_ONLY 0x0100
#define B_WATCH_RECURSIVELY 0x0200
#define B_WATCH_DIRECTORIES_ONLY 0x0400
// NOTE: B_WATCH_RECURSIVELY usually implies to watch for file changes as well,
// if that is not desired, add B_WATCH_DIRECTORIES_ONLY to the flags.
#define B_PATH_MONITOR '_PMN'
namespace BPrivate {
class BPathMonitor {
public:
class BWatchingInterface;
public:
static status_t StartWatching(const char* path, uint32 flags,
const BMessenger& target);
static status_t StopWatching(const char* path,
const BMessenger& target);
static status_t StopWatching(const BMessenger& target);
static void SetWatchingInterface(
BWatchingInterface* watchingInterface);
// pass NULL to reset to default
private:
BPathMonitor();
~BPathMonitor();
static status_t _InitIfNeeded();
static void _Init();
};
/*! 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);
};
} // namespace BPrivate
#endif // _PATH_MONITOR_H