views:

598

answers:

5

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. Does anyone know the tricks? Thanks! :-)

+4  A: 

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

diciu
+3  A: 

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

JamesEggers
I may misunderstand what you intend to do here. Add logic to timer tick? Does that mean you intend to get a directory listing every tick and compare it? No! Don't do that!
Zan Lynx
+3  A: 

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
A: 

Thank you for your answers :-) one from each world

Allanrbo
+3  A: 

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

benlumley