-
-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Labels
CoreEngine Core Module relatedEngine Core Module related
Description
Overview
We want to look for timestamp and directory changes and have a callback installed on files to indicate changes.
Windows - ReadDirectoryChangesW
MacOS -
FSEventStreamCreate(
NULL,
&Callback,
NULL,
paths,
kFSEventStreamEventIdSinceNow,
0.1,
kFSEventStreamCreateFlagFileEvents
);
Unix -
int fd = inotify_init1(IN_NONBLOCK);
int wd = inotify_add_watch(
fd,
"assets",
IN_MODIFY | IN_CREATE | IN_DELETE | IN_MOVED_TO
);
Register OS functions and poll them eveyrframe to drain the file changes queue.
typedef enum RZ_FileChangeType
{
RZ_FILE_CHANGE_MODIFIED,
RZ_FILE_CHANGE_ADDED,
RZ_FILE_CHANGE_REMOVED
} RZ_FileChangeType;
typedef struct RZ_FileChange
{
const char* path;
RZ_FileChangeType type;
} RZ_FileChange;
typedef struct RZ_FileWatcher RZ_FileWatcher;
typedef void (*RZ_FileWatcherPollFn)(
RZ_FileWatcher* watcher,
RZ_FileChange* outChanges,
int* inOutCount,
int maxChanges
);
typedef void (*RZ_FileWatcherDestroyFn)(RZ_FileWatcher* watcher);
struct RZ_FileWatcher
{
void* platform; // OS-specific state
RZ_FileWatcherPollFn poll;
RZ_FileWatcherDestroyFn destroy;
};
RZ_FileWatcher* RZ_CreateFileWatcher_Windows(const char* path);
RZ_FileWatcher* RZ_CreateFileWatcher_Linux(const char* path);
RZ_FileWatcher* RZ_CreateFileWatcher_Mac(const char* path);
RZ_FileWatcher* RZ_CreateFileWatcher_Polling(const char* path);
RZ_FileChange changes[64];
int changeCount = 0;
fileWatcher->poll(
fileWatcher,
changes,
&changeCount,
64
);
for (int i = 0; i < changeCount; i++)
{
AssetSystem_OnFileChanged(&changes[i]);
}Metadata
Metadata
Assignees
Labels
CoreEngine Core Module relatedEngine Core Module related