how to watch a File System for change

I'm doing a project in a course at my university on distributed systems. I'm planning on creating something similar to Dropbox ( ), but with some sort of non-centralized peer-to-peer twist to it. For this i need some method of detecting change in a directory structure. How do you think Dropbox do this? Their implementation works remarkably well. I'm wonder if they use FileSystemWatcher from the win32 api on windows, and something similar and platform dependent on Linux and Mac.


To my knowledge, DropBox (and the like) uses a Windows service (or a daemon on the Linux/Mac side) to monitor the file system. Creating such in .Net is very easy and this scenario is usually the textbook example for Windows Services. I believe doing a similar thing in C++ would be fairly straight forward as well.

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

Under Mac OS X Leopard there's the FSEvents API that allows you to register for notifications of file-system changes:

On the Linux side, there's the horribly undocumented inotify. If you don't mind using glib, there's the GFileMonitor class, which is really easy to use. I don't think it's portable though, so it would be Linux-only.

eduffy mentioned inotify ....

I saw this a while back, based on inotify. called incron, it adds cron like functionality to incron.

Need Your Help

Execute cmd command using maven pom.xml file

java maven cmd pom.xml

I want to run multiple CMD commands in maven using single pom.xml.