aboutsummaryrefslogtreecommitdiff
path: root/src/hotload.h
blob: 8d012f23ba073982758581b9939dfe46e799f39a (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
33
34
35
36
37
38
#ifndef SKHD_HOTLOAD_H
#define SKHD_HOTLOAD_H

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

#define HOTLOADER_CALLBACK(name) void name(ConstFSEventStreamRef stream,\
                                           void *context,\
                                           size_t count,\
                                           void *paths,\
                                           const FSEventStreamEventFlags *flags,\
                                           const FSEventStreamEventId *ids)
typedef HOTLOADER_CALLBACK(hotloader_callback);

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

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

    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, const char *file);
bool hotloader_watched_file(struct hotloader *hotloader, char *absolutepath);

#endif