rename filewatcher struct
This commit is contained in:
@@ -32,14 +32,14 @@ typedef struct hiWatchPaths {
|
||||
struct sc_array_watch watches;
|
||||
} hiWatchPaths;
|
||||
|
||||
typedef struct hiFileWatcherContext {
|
||||
typedef struct hiFileWatcher {
|
||||
thrd_t thread;
|
||||
mtx_t mutex;
|
||||
cnd_t cond;
|
||||
int running;
|
||||
struct hiWatchPaths watchpaths;
|
||||
struct hiFileEvents events;
|
||||
} hiFileWatcherContext;
|
||||
} hiFileWatcher;
|
||||
|
||||
/*
|
||||
* File Events
|
||||
@@ -80,7 +80,7 @@ void hi_file_event_destroy(hiFileEvent *event) {
|
||||
}
|
||||
}
|
||||
|
||||
hiFileEvent hi_file_event_pop(hiFileWatcherContext *ctx) {
|
||||
hiFileEvent hi_file_event_pop(hiFileWatcher *ctx) {
|
||||
mtx_lock(&ctx->mutex);
|
||||
hiFileEvent *last = &sc_array_last(&ctx->events.events);
|
||||
hiFileEvent e = *last;
|
||||
@@ -204,11 +204,11 @@ static void watch_paths_destroy(hiWatchPaths *paths) {
|
||||
// Declare the thread func
|
||||
int file_watcher_watch(void *arg);
|
||||
|
||||
hiFileWatcherContext *hi_file_watcher_create() {
|
||||
hiFileWatcher *hi_file_watcher_create() {
|
||||
|
||||
// Allocate context
|
||||
hiFileWatcherContext *context = malloc(sizeof(hiFileWatcherContext));
|
||||
memset(context, 0, sizeof(hiFileWatcherContext));
|
||||
hiFileWatcher *context = malloc(sizeof(hiFileWatcher));
|
||||
memset(context, 0, sizeof(hiFileWatcher));
|
||||
|
||||
if (context) {
|
||||
if (!HILOADRES(watch_paths_init(&context->watchpaths))) {
|
||||
@@ -236,7 +236,7 @@ hiFileWatcherContext *hi_file_watcher_create() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HiloadResult hi_file_watcher_add(struct hiFileWatcherContext *ctx,
|
||||
HiloadResult hi_file_watcher_add(struct hiFileWatcher *ctx,
|
||||
const char *filename, u32 flags) {
|
||||
if (!ctx) {
|
||||
sc_log_error("Attempted to add file watcher for '%s' with null context\n",
|
||||
@@ -255,7 +255,7 @@ HiloadResult hi_file_watcher_add(struct hiFileWatcherContext *ctx,
|
||||
return HILOAD_OK;
|
||||
}
|
||||
|
||||
HiloadResult hi_file_watcher_remove(struct hiFileWatcherContext *ctx,
|
||||
HiloadResult hi_file_watcher_remove(struct hiFileWatcher *ctx,
|
||||
const char *filename) {
|
||||
if (!ctx) {
|
||||
return HILOAD_FAIL;
|
||||
@@ -272,13 +272,13 @@ HiloadResult hi_file_watcher_remove(struct hiFileWatcherContext *ctx,
|
||||
return HILOAD_OK;
|
||||
}
|
||||
|
||||
void hi_file_watcher_notify(hiFileWatcherContext *ctx) {
|
||||
void hi_file_watcher_notify(hiFileWatcher *ctx) {
|
||||
if (ctx && ctx->running) {
|
||||
cnd_signal(&ctx->cond);
|
||||
}
|
||||
}
|
||||
|
||||
void hi_file_watcher_destroy(hiFileWatcherContext *ctx) {
|
||||
void hi_file_watcher_destroy(hiFileWatcher *ctx) {
|
||||
if (!ctx)
|
||||
return;
|
||||
|
||||
@@ -293,7 +293,7 @@ void hi_file_watcher_destroy(hiFileWatcherContext *ctx) {
|
||||
}
|
||||
|
||||
int file_watcher_watch(void *arg) {
|
||||
hiFileWatcherContext *ctx = (hiFileWatcherContext *)arg;
|
||||
hiFileWatcher *ctx = (hiFileWatcher *)arg;
|
||||
sc_log_set_thread_name("File Watcher");
|
||||
|
||||
char buf[4096] __attribute__((aligned(__alignof__(struct inotify_event))));
|
||||
|
||||
Reference in New Issue
Block a user