uvw 2.12.1
Loading...
Searching...
No Matches
fs_event.h
1#ifndef UVW_FS_EVENT_INCLUDE_H
2#define UVW_FS_EVENT_INCLUDE_H
3
4#include <string>
5#include <type_traits>
6#include <uv.h>
7#include "handle.hpp"
8#include "loop.h"
9#include "util.h"
10
11namespace uvw {
12
13namespace details {
14
15enum class UVFsEventFlags : std::underlying_type_t<uv_fs_event_flags> {
16 WATCH_ENTRY = UV_FS_EVENT_WATCH_ENTRY,
17 STAT = UV_FS_EVENT_STAT,
18 RECURSIVE = UV_FS_EVENT_RECURSIVE
19};
20
21enum class UVFsEvent : std::underlying_type_t<uv_fs_event> {
22 RENAME = UV_RENAME,
23 CHANGE = UV_CHANGE
24};
25
26} // namespace details
27
34 FsEventEvent(const char *pathname, Flags<details::UVFsEvent> events);
35
42 const char *filename;
43
53};
54
68class FsEventHandle final: public Handle<FsEventHandle, uv_fs_event_t> {
69 static void startCallback(uv_fs_event_t *handle, const char *filename, int events, int status);
70
71public:
72 using Watch = details::UVFsEvent;
73 using Event = details::UVFsEventFlags;
74
75 using Handle::Handle;
76
81 bool init();
82
100 void start(const std::string &path, Flags<Event> flags = Flags<Event>{});
101
119 void start(const std::string &path, Event flag);
120
124 void stop();
125
130 std::string path() noexcept;
131};
132
133} // namespace uvw
134
135#ifndef UVW_AS_LIB
136# include "fs_event.cpp"
137#endif
138
139#endif // UVW_FS_EVENT_INCLUDE_H
Utility class to handle flags.
Definition util.h:80
The FsEventHandle handle.
Definition fs_event.h:68
void stop()
Stops polling the file descriptor.
void start(const std::string &path, Flags< Event > flags=Flags< Event >{})
Starts watching the specified path.
bool init()
Initializes the handle.
void start(const std::string &path, Event flag)
Starts watching the specified path.
std::string path() noexcept
Gets the path being monitored.
Handle base class.
Definition handle.hpp:26
uvw default namespace.
Definition async.h:8
FsEventEvent event.
Definition fs_event.h:33
const char * filename
The path to the file being monitored.
Definition fs_event.h:42
Flags< details::UVFsEvent > flags
Detected events all in one.
Definition fs_event.h:52