diff options
author | koekeishiya <aasvi93@hotmail.com> | 2018-07-20 11:20:18 +0200 |
---|---|---|
committer | koekeishiya <aasvi93@hotmail.com> | 2018-07-20 11:20:18 +0200 |
commit | 55a930709a909cca7d518bd838366104df341ae3 (patch) | |
tree | 4e1ce9b1d7044ea1b85ec87a1b22e8db5049ec02 /src/hotload.h | |
parent | 0b38f59cf5ec2c6de20697959e8c1760f074aef8 (diff) | |
download | skhd-55a930709a909cca7d518bd838366104df341ae3.tar.gz skhd-55a930709a909cca7d518bd838366104df341ae3.zip |
hotloader: support for watching all files of given extension (or all, if not specified) in target directory
Diffstat (limited to 'src/hotload.h')
-rw-r--r-- | src/hotload.h | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/hotload.h b/src/hotload.h index 78ed07b..7f11f6d 100644 --- a/src/hotload.h +++ b/src/hotload.h @@ -7,6 +7,19 @@ #define HOTLOADER_CALLBACK(name) void name(char *absolutepath, char *directory, char *filename) typedef HOTLOADER_CALLBACK(hotloader_callback); +enum watch_kind +{ + WATCH_KIND_INVALID, + WATCH_KIND_CATALOG, + WATCH_KIND_FILE +}; + +struct watched_catalog +{ + char *directory; + char *extension; +} + struct watched_file { char *absolutepath; @@ -14,6 +27,15 @@ struct watched_file char *filename; }; +struct watched_entry +{ + enum watch_kind kind; + union { + struct watched_file file_info; + struct watched_catalog catalog_info; + }; +}; + struct hotloader { FSEventStreamEventFlags flags; @@ -22,12 +44,13 @@ struct hotloader bool enabled; hotloader_callback *callback; - struct watched_file watch_list[32]; + struct watched_entry watch_list[32]; unsigned watch_count; }; bool hotloader_begin(struct hotloader *hotloader, hotloader_callback *callback); void hotloader_end(struct hotloader *hotloader); +void hotloader_add_catalog(struct hotloader *hotloader, char *directory, char *extension); void hotloader_add_file(struct hotloader *hotloader, char *file); #endif |