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 ( getdropbox.com ), 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.

Answers


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.

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


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

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


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.

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


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.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.