aboutsummaryrefslogtreecommitdiff
path: root/src/hotload.h
blob: ad782fba39b4e76650bee5aaeb333a0f3ff93326 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef SKHD_HOTLOAD_H
#define SKHD_HOTLOAD_H

#include <stdbool.h>
#include <Carbon/Carbon.h>

#define HOTLOADER_CALLBACK(name) void name(char *absolutepath, char *directory, char *filename)
typedef HOTLOADER_CALLBACK(hotloader_callback);

struct watched_file
{
    char *directory;
    char *filename;
};

struct hotloader
{
    FSEventStreamEventFlags flags;
    FSEventStreamRef stream;
    CFArrayRef path;
    bool enabled;

    hotloader_callback *callback;
    struct watched_file watch_list[32];
    unsigned watch_count;
};

bool hotloader_begin(struct hotloader *hotloader, hotloader_callback *callback);
void hotloader_end(struct hotloader *hotloader);
void hotloader_add_file(struct hotloader *hotloader, char *file);

#endif