Sets up watcher and returns whether that worked. Call it on an empty watcher, once; afterwards add folders with add_directories.
callbackis called byprocess_changesfor each change, ascallback(watcher, change, user_data). It may not benull.user_datais passed on to the callback.events_to_watchselects the events worth reporting (default.ALL_EVENTS); others are dropped.merge_window_seconds(default0.1) is how long a path must be quiet before its changes are reported, so a burst of writes to one file gives one report.0reports at the nextprocess_changes.watch_recursively(defaulttrue) includes the sub-folders of watched folders, also ones made later.event_buffer_sizesizes the system's event buffer for each watched folder (default 8000); on Linux a burst of changes that overflows it is reported asSCAN_CHILDREN.verboselogs each change just before its callback, throughcontext.logger: the path and the events.
It returns false, and leaves the watcher empty, for a null callback, a negative or non-finite window, a buffer size of 0 or
less, or when the system refuses. Calling it on a watcher that is already set up fails an assertion. Pair each successful call with deinit.
on_change :: (watcher: *File_Watcher(void), change: *File_Change, data: *void) {}
watcher: File_Watcher;
assert(!init(*watcher, on_change, merge_window_seconds = -1));
assert(!init(*watcher, on_change, event_buffer_size = 0));
deinit(*watcher); // nothing was set up, so nothing to releaseDoesn't run in the browser (skipped on wasm).
init :: (
watcher: *$T/File_Watcher,
callback: T.File_Watcher_Callback,
user_data: *T.User_Data = null,
events_to_watch: File_Change_Event = .ALL_EVENTS,
merge_window_seconds: float = 0.1,
watch_recursively := true,
verbose := false,
event_buffer_size: s32 = DEFAULT_BUFFER_SIZE
) -> success: bool
Sets up watcher and returns whether that worked. Call it on an empty watcher, once; afterwards add folders with add_directories.
callbackis called byprocess_changesfor each change, ascallback(watcher, change, user_data). It may not benull.user_datais passed on to the callback.events_to_watchselects the events worth reporting (default.ALL_EVENTS); others are dropped.merge_window_seconds(default0.1) is how long a path must be quiet before its changes are reported, so a burst of writes to one file gives one report.0reports at the nextprocess_changes.watch_recursively(defaulttrue) includes the sub-folders of watched folders, also ones made later.event_buffer_sizesizes the system's event buffer for each watched folder (default 8000); on Linux a burst of changes that overflows it is reported asSCAN_CHILDREN.verboselogs each change just before its callback, throughcontext.logger: the path and the events.
It returns false, and leaves the watcher empty, for a null callback, a negative or non-finite window, a buffer size of 0 or
less, or when the system refuses. Calling it on a watcher that is already set up fails an assertion. Pair each successful call with deinit.
Parameters
- watcher: *$T/File_Watcher
- callback: T.File_Watcher_Callback
- user_data: *T.User_Data
- events_to_watch: File_Change_Event
- merge_window_seconds: float
- watch_recursively := true
- verbose := false
- event_buffer_size: s32
Returns
- success: bool
on_change :: (watcher: *File_Watcher(void), change: *File_Change, data: *void) {}
watcher: File_Watcher;
assert(!init(*watcher, on_change, merge_window_seconds = -1));
assert(!init(*watcher, on_change, event_buffer_size = 0));
deinit(*watcher); // nothing was set up, so nothing to releaseDoesn't run in the browser (skipped on wasm).