How to be notified of file/directory change in C/C++, ideally using POSIX

Linux users can use inotify

inotify is a Linux kernel subsystem that provides file system event notification.

Some goodies for Windows fellows:

  • File Change Notification on MSDN
  • "When Folders Change" article
  • File System Notification on Change

The Qt library has a QFileSystemWatcher class which provides cross platform notifications when a file changes. Even if you are not using Qt, because the source is available you could have a look at it as a sample for your own implementation. Qt has separate implementations for Windows, Linux and Mac.

Tags:

C++

C

Posix