fswatch 1.20.1
Loading...
Searching...
No Matches
fsevents_monitor.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2014-2025 Enrico M. Crisostomo
3 *
4 * This program is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License as published by the Free Software
6 * Foundation; either version 3, or (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11 * details.
12 *
13 * You should have received a copy of the GNU General Public License along with
14 * this program. If not, see <http://www.gnu.org/licenses/>.
15 */
25
26#ifndef FSW_FSEVENT_MONITOR_H
27# define FSW_FSEVENT_MONITOR_H
28
29# include "monitor.hpp"
30# include <CoreServices/CoreServices.h>
31# include <memory>
32
33namespace fsw
34{
41 {
42 public:
43
63 static constexpr const char *DARWIN_EVENTSTREAM_NO_DEFER = "darwin.eventStream.noDefer";
64
68 fsevents_monitor(std::vector<std::string> paths,
70 void *context = nullptr);
71 ~fsevents_monitor() override;
72 fsevents_monitor(const fsevents_monitor& orig) = delete;
73 fsevents_monitor& operator=(const fsevents_monitor& that) = delete;
74
75 protected:
83 void run() override;
84
88 void on_stop() override;
89
90 private:
91 class Impl;
92 std::unique_ptr<Impl> pImpl;
93
94 static void fsevents_callback(ConstFSEventStreamRef streamRef,
95 void *clientCallBackInfo,
96 size_t numEvents,
97 void *eventPaths,
98 const FSEventStreamEventFlags eventFlags[],
99 const FSEventStreamEventId eventIds[]);
100
101 bool no_defer();
102 static CFArrayRef copy_cf_paths(const std::vector<std::string>& paths);
103 void create_stream(CFArrayRef pathsToWatch);
104 };
105}
106
107#endif /* FSW_FSEVENT_MONITOR_H */
Definition fsevents_monitor.cpp:40
fsevents_monitor(std::vector< std::string > paths, FSW_EVENT_CALLBACK *callback, void *context=nullptr)
Constructs an instance of this class.
void on_stop() override
Execute an implementation-specific stop handler.
Definition fsevents_monitor.cpp:189
void run() override
Executes the monitor loop.
Definition fsevents_monitor.cpp:115
static constexpr const char * DARWIN_EVENTSTREAM_NO_DEFER
Custom monitor property used to enable the kFSEventStreamCreateFlagNoDefer flag in the event stream.
Definition fsevents_monitor.hpp:63
std::vector< std::string > paths
List of paths to watch.
Definition monitor.hpp:527
void * context
Pointer to context data that will be passed to the monitor::callback.
Definition monitor.hpp:547
FSW_EVENT_CALLBACK * callback
Callback to which change events should be notified.
Definition monitor.hpp:542
monitor(std::vector< std::string > paths, FSW_EVENT_CALLBACK *callback, void *context=nullptr)
Constructs a monitor watching the specified paths.
Definition monitor.cpp:50
Header of the fsw::monitor class.
Main namespace of libfswatch.
Definition event.cpp:24
void FSW_EVENT_CALLBACK(const std::vector< event > &, void *)
Function definition of an event callback.
Definition monitor.hpp:57