summaryrefslogtreecommitdiff
path: root/dmonwrapper.h
diff options
context:
space:
mode:
authorJosh Ferrell <josh@vector35.com>2024-01-24 16:37:50 -0500
committerJosh Ferrell <josh@vector35.com>2024-02-02 15:40:49 -0500
commit1e0b3ca09efa1739e2f00181c7ab2435ca5eae7a (patch)
tree039e12a90e05b72b32ae908acf504bc4c8a3fe2a /dmonwrapper.h
parent668f9cb0e0ea45c6d2cdc802dbe99b12f5623fff (diff)
Add dmon
Diffstat (limited to 'dmonwrapper.h')
-rw-r--r--dmonwrapper.h33
1 files changed, 33 insertions, 0 deletions
diff --git a/dmonwrapper.h b/dmonwrapper.h
new file mode 100644
index 00000000..ac588329
--- /dev/null
+++ b/dmonwrapper.h
@@ -0,0 +1,33 @@
+#pragma once
+
+#include <filesystem>
+#include <functional>
+#include <map>
+#include <mutex>
+#include <vector>
+#define DMON_MAX_WATCHES 256
+#include "vendor/dmon/dmon.h"
+
+
+typedef std::function<void(dmon_action action, std::string dirname, std::string filename, std::string oldname)> CallbackFunction;
+
+class DMonWrapper
+{
+ struct CallbackContext
+ {
+ CallbackFunction callback;
+ };
+
+ static bool DMON_INITIALIZED;
+ static std::mutex DMON_MUTEX;
+
+ std::map<uint32_t, CallbackContext*> m_callbacks;
+
+public:
+ DMonWrapper();
+ ~DMonWrapper();
+
+ dmon_watch_id Watch(const std::filesystem::path& path, CallbackFunction callback, bool recursive = false);
+ void Unwatch(dmon_watch_id watchId);
+ std::vector<dmon_watch_id> GetWatchIds();
+};