Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // do this once somehwere
- CreateThread(
- NULL,
- 0,
- watch_for_changes_in_the_variables_file,
- NULL,
- 0,
- NULL
- );
- func s32 WINAPI watch_for_changes_in_the_variables_file(void* param)
- {
- HANDLE file = CreateFileA(
- ".",
- GENERIC_READ,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS,
- NULL
- );
- FILE_NOTIFY_INFORMATION buffer[16] = ZERO;
- s32 bytes_returned;
- while(true)
- {
- ReadDirectoryChangesW(
- file,
- buffer,
- sizeof(buffer),
- false,
- FILE_NOTIFY_CHANGE_LAST_WRITE,
- &bytes_returned,
- NULL,
- NULL
- );
- if(wcscmp(L"variables.txt", buffer[0].FileName) == 0)
- {
- read_hot_reload_variables();
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement