aboutsummaryrefslogtreecommitdiff
path: root/src/hotload.h
blob: 9b2d666dfa11bdec8cedfcb02efbb6d1795889fb (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
39
#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);

char *file_directory(const char *file);
char *file_name(const char *file);

#endif