From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.1 required=5.0 tests=AWL,HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 604FCBC69 for ; Mon, 22 Oct 2007 21:57:59 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAOKdHEfAXQImh2dsb2JhbACCPjSLZQEBAQgKKQ X-IronPort-AV: E=Sophos;i="4.21,313,1188770400"; d="scan'208";a="18481404" Received: from discorde.inria.fr ([192.93.2.38]) by mail4-smtp-sop.national.inria.fr with ESMTP; 22 Oct 2007 21:57:59 +0200 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l9MJvwfU032619 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Mon, 22 Oct 2007 21:57:58 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAKadHEfRVYC5kmdsb2JhbACCPjSLZQEBAQEHBAQTFg X-IronPort-AV: E=Sophos;i="4.21,313,1188770400"; d="scan'208";a="3500494" Received: from fk-out-0910.google.com ([209.85.128.185]) by mail1-smtp-roc.national.inria.fr with ESMTP; 22 Oct 2007 21:57:58 +0200 Received: by fk-out-0910.google.com with SMTP id z22so1536619fkz for ; Mon, 22 Oct 2007 12:57:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; bh=QpyrDX8qH1vCwq6Q2Fjg5artuce7eFLLUJJHfYOppfY=; b=LkQ/tBZ3UgvgxYxaxxoyfEsr0XmjAbX/rlGcBz+H2WDM9u7ybfrMcaKDhmyYBCpVSnHlVPS3tBxdKOjg0liZ5e7SD2rEf06PghlKi31OnaTXgxcmYquhk6lrxBuUSMDJaQlWn54mWGKA7qQCj3S5I3ecJTbVcfEFE47Zy03qCys= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=pYQLSQ9MlNgAMWm131IIL9D8ICBCCxdlk1aqiAv0pkvwdgWcAZ1MZVGTXO9JKQqG6M5NilfrF9Zv3/kOJiA3iBX2e1g2AviyjCs0AVNy2qaMAwt7jEDTo4cg4wUHZCSTUrtCH6PEVMxfTE1U2f9GaGMIr6RbkxqW52DkVBwFC+w= Received: by 10.82.112.3 with SMTP id k3mr4692574buc.1193083077176; Mon, 22 Oct 2007 12:57:57 -0700 (PDT) Received: by 10.82.120.16 with HTTP; Mon, 22 Oct 2007 12:57:57 -0700 (PDT) Message-ID: Date: Mon, 22 Oct 2007 15:57:57 -0400 From: "Orlin Grigorov" To: "Karl Zilles" Subject: Re: [Caml-list] How to monitor a specific file for changes Cc: caml-list@inria.fr In-Reply-To: <471CFD24.30805@1969web.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_22884_21137356.1193083077158" References: <20071023052001.517e957e.mle+ocaml@mega-nerd.com> <471CFD24.30805@1969web.com> X-Miltered: at discorde with ID 471D00C6.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; W8:98 W8:98 wrote:01 wrote:01 unix:01 unix:01 caml-list:01 let:03 let:03 stat:07 stat:07 platforms:09 platforms:09 it'll:09 it'll:09 ------=_Part_22884_21137356.1193083077158 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Using "Unix.stat" works perfectly for my purpose! On both platforms, hurray! THANK YOU! On 10/22/07, Karl Zilles wrote: > > Orlin Grigorov wrote: > > 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? > > Just stat it. You can stat it every second and never notice any > performance issue. In fact you can stat a whole directory of files > every second and never notice. It'll work cross platform, and it's easy: > > let modtime file = > let filedata = Unix.stat file in > filedata.Unix.st_mtime > > > In a loop, compare the modtime to the previous modtime, then > Unix.sleep 1; > ------=_Part_22884_21137356.1193083077158 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Using "Unix.stat" works perfectly for my purpose!   On both platforms, hurray!    THANK YOU!

On 10/22/07, Karl Zilles < zilles@1969web.com> wrote:
Orlin Grigorov wrote:
> 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?

Just stat it.  You can stat it every second and never notice any
performance issue.  In fact you can stat a whole directory of files
every second and never notice.  It'll work cross platform, and it's easy:

let modtime file =
         let filedata = Unix.stat file in
         filedata.Unix.st_mtime


In a loop, compare the modtime to the previous modtime, then
Unix.sleep 1;

------=_Part_22884_21137356.1193083077158--