Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Date: 2007nov6 Library: FAM Q. How can my program efficiently detect when files in a folder have changed? A. On Linux/Unix the answer is FAM (File Alteration Monitor). More info here: http://en.wikipedia.org/wiki/File_alteration_monitor On Linux, inotify has replaced FAM: http://en.wikipedia.org/wiki/Inotify (Do "man inotify" for info) These have a rather nice interface. You open a folder and wait on a read. You get data when a change occurs. Eventually, close the handle. Its like reading a stream. My only complaint is that, at least in my last try, they could not monitor a tree. On Windows, use FindFirstChangeNotification() Its API is more painful. Windows now has ReadDirectoryChanges and FileSystemWatcher.
Add a commentSign in to add a comment