From 3ee8f6ef0fd42f28cbaadb447e7955c416ec573d Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Tue, 11 Oct 2022 20:44:53 -0600 Subject: [PATCH] fix(fsevents): allow on older mac sdk's mainly useful for nixos on macos which is stuck on the old sdk Signed-off-by: Rudi Grinberg ps-id: 32403256-aef1-41bb-b674-272998e51c3c --- CHANGES.md | 2 ++ src/fsevents/fsevents_stubs.c | 19 ++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a1813b46f0d..3035409dff9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,8 @@ 3.5.0 (unreleased) ------------------ +- Enable file watching on MacOS SDK < 10.13. (#6218, @rgrinberg) + - Sandbox running cinaps actions starting from cinaps 1.1 (#6176, @rgrinberg) - Add a `runtime_deps` field in the `cinaps` stanza to specify runtime diff --git a/src/fsevents/fsevents_stubs.c b/src/fsevents/fsevents_stubs.c index c1c65797213..093b7d7136c 100644 --- a/src/fsevents/fsevents_stubs.c +++ b/src/fsevents/fsevents_stubs.c @@ -7,10 +7,8 @@ #include #if defined(__APPLE__) -#include -#endif -#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 +#include #include #include @@ -89,9 +87,13 @@ static void dune_fsevents_callback(const FSEventStreamRef streamRef, if (!(interesting_flags & flags)) { continue; } + CFStringRef cf_path; +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 CFDictionaryRef details = CFArrayGetValueAtIndex(eventPaths, i); - CFStringRef cf_path = - CFDictionaryGetValue(details, kFSEventStreamEventExtendedDataPathKey); + cf_path = CFDictionaryGetValue(details, kFSEventStreamEventExtendedDataPathKey); +#else + cf_path = (CFStringRef) CFArrayGetValueAtIndex(eventPaths, i); +#endif CFIndex len = CFStringGetLength(cf_path); CFIndex byte_len; CFIndex res = @@ -152,7 +154,9 @@ CAMLprim value dune_fsevents_create(value v_paths, value v_latency, const FSEventStreamEventFlags flags = kFSEventStreamCreateFlagNoDefer | +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 kFSEventStreamCreateFlagUseExtendedData | +#endif kFSEventStreamCreateFlagUseCFTypes | kFSEventStreamCreateFlagFileEvents; dune_fsevents_t *t; @@ -316,7 +320,9 @@ static const FSEventStreamEventFlags all_flags[] = { kFSEventStreamEventFlagOwnEvent, kFSEventStreamEventFlagItemIsHardlink, kFSEventStreamEventFlagItemIsLastHardlink, +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101300 kFSEventStreamEventFlagItemCloned, +#endif }; CAMLprim value dune_fsevents_raw(value v_flags) { @@ -338,8 +344,7 @@ CAMLprim value dune_fsevents_available(value unit) { #else -static char *unavailable_message = - "fsevents is only available on macos >= 10.13"; +static char *unavailable_message = "fsevents is only available on macos"; CAMLprim value dune_fsevents_stop(value v_t) { caml_failwith(unavailable_message);