Version française
Home     About     Download     Resources     Contact us    
Browse thread
How to monitor a specific file for changes
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Sylvain Le Gall <sylvain@l...>
Subject: Re: How to monitor a specific file for changes
On 22-10-2007, Orlin Grigorov <ogrigorov@gmail.com> wrote:
> This time I've done my research, but still I cannot find a good answer.
> Basically, I need to make a little ocaml process, which runs in the
> background and monitors a specific file for changes.   When a change occurs,
> I want it to back-up a copy of the version of the file at that moment.
> So, what I need is to set some signal or event, which will happen every time
> that file is changed.
>
> Can you guys help me do it?
>

The thing you describe should be handled at OS level (at least this is
kind of notification are bound to OS). This means, you don't have high
level functions that are multi-OS.

If you use linux 2.6, take a look at ocaml-inotify, which helps you to
wait for specific event on some file descriptors (also work for
directories):

http://tab.snarc.org/projects/ocaml_inotify/

If you use older linux version, solaris, macos or windows, i have no
answer (but i am sure this kind of things already exists).

Regards,
Sylvain Le Gall