uvw 3.1.0
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 "config.h"
8#include "enum.hpp"
9#include "handle.hpp"
10#include "loop.h"
11#include "util.h"
12
13namespace uvw {
14
15namespace details {
16
17enum class uvw_fs_event_flags : std::underlying_type_t<uv_fs_event_flags> {
18 WATCH_ENTRY = UV_FS_EVENT_WATCH_ENTRY,
19 STAT = UV_FS_EVENT_STAT,
20 RECURSIVE = UV_FS_EVENT_RECURSIVE,
21 _UVW_ENUM = 0
22};
23
24enum class uvw_fs_event : std::underlying_type_t<uv_fs_event> {
25 RENAME = UV_RENAME,
26 CHANGE = UV_CHANGE
27};
28
29} // namespace details
30
33 fs_event_event(const char *pathname, details::uvw_fs_event events);
34
41 const char *filename;
42
51 details::uvw_fs_event flags;
52};
53
67class fs_event_handle final: public handle<fs_event_handle, uv_fs_event_t, fs_event_event> {
68 static void start_callback(uv_fs_event_t *hndl, const char *filename, int events, int status);
69
70public:
71 using watch = details::uvw_fs_event;
72 using event_flags = details::uvw_fs_event_flags;
73
74 using handle::handle;
75
80 int init() final;
81
99 int start(const std::string &path, event_flags flags = event_flags::_UVW_ENUM);
100
105 int stop();
106
111 std::string path() noexcept;
112};
113
114} // namespace uvw
115
116#ifndef UVW_AS_LIB
117# include "fs_event.cpp"
118#endif
119
120#endif // UVW_FS_EVENT_INCLUDE_H
The fs event handle.
Definition: fs_event.h:67
std::string path() noexcept
Gets the path being monitored.
int start(const std::string &path, event_flags flags=event_flags::_UVW_ENUM)
Starts watching the specified path.
int init() final
Initializes the handle.
int stop()
Stops polling the file descriptor.
Handle base class.
Definition: handle.hpp:23
uvw default namespace.
Definition: async.h:8
Fs event event.
Definition: fs_event.h:32
details::uvw_fs_event flags
Detected events all in one.
Definition: fs_event.h:51
const char * filename
The path to the file being monitored.
Definition: fs_event.h:41