How to watch the file system for change

I am working on a project at a university in distributed systems. I plan to create something similar to Dropbox (getdropbox.com), but with some decentralized, scrupulous appeal to it. To do this, I need some method of detecting changes in the directory structure. Do you think Dropbox does this? Their implementation works remarkably well. I am wondering if they use FileSystemWatcher from win32 api in windows, but something similar also depends on Linux and Mac platforms.

+3
source share
4 answers

To my knowledge, DropBox (and the like) uses the Windows service (or daemon on the Linux / Mac side) to monitor the file system. Creating one in .Net is very simple, and this script is usually an example tutorial for Windows services. I believe that doing a similar thing in C ++ would be pretty straight forward.

Here is a link to a simple .Net tutorial on how to create a service on Windows. All you need to do for your solution is to add monitor logic to the Timer.Tick () event.

http://www.developer.com/net/csharp/article.php/2173801

+1
source

Mac OS X Leopard has the FSEvents API, which allows you to register for file system change notifications:

http://googlemac.blogspot.com/2008/03/file-system-change-logger-for-leopard.html

+4
source

On the Linux side, there is a terribly undocumented inotify. If you don't mind using glib, the GFileMonitor is a class that is very easy to use. I do not think it is portable, so it will only be Linux.

+3
source

eduffy mentioned inotify ....

I saw this some time ago based on inotify. called incron, it adds cron functions like incron.

http://www.linux.com/feature/144666

+3
source

All Articles