libwebsockets
Lightweight C library for HTML5 websockets
Loading...
Searching...
No Matches
lws-dir-notify.h File Reference

Go to the source code of this file.

Typedefs

typedef void(* lws_dir_notify_cb_t) (const char *path, int is_file, void *user)
 

Functions

LWS_VISIBLE LWS_EXTERN struct lws_dir_notify * lws_dir_notify_create (struct lws_context *ctx, const char *path, lws_dir_notify_cb_t cb, void *user)
 
LWS_VISIBLE LWS_EXTERN void lws_dir_notify_destroy (struct lws_dir_notify **pdn)
 

Typedef Documentation

◆ lws_dir_notify_cb_t

typedef void(* lws_dir_notify_cb_t) (const char *path, int is_file, void *user)

lws_dir_notify_cb_t() - Callback for directory/file modification events

Parameters
pathThe absolute path of the file or directory that was modified
is_fileNon-zero if the modified entry was a file, zero if a directory
userOpaque pointer passed in during lws_dir_notify_create

Definition at line 37 of file lws-dir-notify.h.

Function Documentation

◆ lws_dir_notify_create()

LWS_VISIBLE LWS_EXTERN struct lws_dir_notify * lws_dir_notify_create ( struct lws_context * ctx,
const char * path,
lws_dir_notify_cb_t cb,
void * user )

lws_dir_notify_create() - Create a cross-platform directory/file monitor

Parameters
ctxThe lws_context the monitor should bind to
pathThe absolute path of the directory or file to monitor
cbThe event callback that is routed when changes are detected
userOpaque object passed back in the callback

Returns an allocated and initialized struct lws_dir_notify bound to the context event loop, or NULL on failure.

On Linux, this will use an inotify FD and adopt it into the event loop. On macOS/BSD, this will use kqueue. On Windows, this will use ReadDirectoryChangesW/FindFirstChangeNotification.

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_dir_notify_destroy()

LWS_VISIBLE LWS_EXTERN void lws_dir_notify_destroy ( struct lws_dir_notify ** pdn)

lws_dir_notify_destroy() - Destroy the monitor

Parameters
pdnPointer to the lws_dir_notify pointer to clean up

Closes underlying resources and frees the monitor structure. Sets pointer to NULL.