Files
Alexander Stecher 9f5e7a9eaa fix(watcher): handles associated events (#1379)
* Handles associated events.

* triggers pipeline

* Adjusts comment.

* Uses fixed version.

* Update watch_pattern_test.go

---------

Co-authored-by: Alliballibaba <alliballibaba@gmail.com>
Co-authored-by: Kévin Dunglas <kevin@dunglas.fr>
2025-02-17 23:47:27 +01:00

27 lines
670 B
C

// clang-format off
//go:build !nowatcher
// clang-format on
#include "_cgo_export.h"
#include "wtr/watcher-c.h"
void handle_event(struct wtr_watcher_event event, void *data) {
go_handle_file_watcher_event(
(char *)event.path_name, (char *)event.associated_path_name,
event.effect_type, event.path_type, (uintptr_t)data);
}
uintptr_t start_new_watcher(char const *const path, uintptr_t data) {
void *watcher = wtr_watcher_open(path, handle_event, (void *)data);
if (watcher == NULL) {
return 0;
}
return (uintptr_t)watcher;
}
int stop_watcher(uintptr_t watcher) {
if (!wtr_watcher_close((void *)watcher)) {
return 0;
}
return 1;
}