Created
March 28, 2015 12:27
-
-
Save nlguillemot/f49b730a41c934c07188 to your computer and use it in GitHub Desktop.
Polling for changes in a directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Windows.h> | |
int main() | |
{ | |
// Create a file change notification object that can be used to check for file changes. | |
HANDLE hNotif = FindFirstChangeNotification("C:\\Path\\To\\My\\Directory", TRUE, FILE_NOTIFY_CHANGE_LAST_WRITE); | |
while (1) | |
{ | |
// Wait until a file change notification happens. | |
WaitForSingleObject(hNotif, INFINITY); | |
// You can use ReadDirectoryChangesW to know specifically what changed in your directory | |
// When you know what changed, you can automatically reload the assets corresponding to it. | |
OutputDebugString("A file was written somewhere inside that directory!"); | |
// Get the notification object to start looking for the next change. | |
FindNextChangeNotification(hNotif); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment