Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2007-10-22 (19:30)
From: Orlin Grigorov <ogrigorov@g...>
Subject: Re: [Caml-list] How to monitor a specific file for changes
Well, I'm developing my application in Linux, but after it's done, it will
be used mostly on Mac OS.  So far, on regular basis, I test everything on my
Mac to make sure it's working.

I guess I'll have to find another way then.   One idea I have is to poll the
size of the file every certain amount of time, and if it's
different---there's my event.   Same applies to "date/time last modified".

Is there something I can use successfully on both Linux and Mac about that?

Just to mention that the file is a text file, and it doesn't change very
often.  I mean, it's not constantly changing, so I'm not concerned with
performance and resource issues.

Oh, here's another idea---every certain amount of time, I just compare my
last saved version of the file to the current one---if different, there's my
event.   What do you think?


On 10/22/07, Erik de Castro Lopo <> wrote:
> Orlin Grigorov wrote:
> > Hi.
> >
> > 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.
> If you are on Linux/Unix, have a look at Inotify. The Ocaml bindings are
> here:
> HTH,
> Erik
> --
> -----------------------------------------------------------------
> Erik de Castro Lopo
> -----------------------------------------------------------------
> "Well behaved women rarely make history." -- Dorothy Parker
> _______________________________________________
> Caml-list mailing list. Subscription management:
> Archives:
> Beginner's list:
> Bug reports: