List Info

Thread: "ocaml_beginners"::[] Modification date within Ocaml




"ocaml_beginners"::[] Modification date within Ocaml
user name
2006-06-24 13:41:52
On Saturday 24 June 2006 14:31, roparzhhemon wrote:
>      hello all,
>
>   I'm trying to define within Ocaml a function
>
>  modification_date : string -> Int64
>
>   such that modification_date(fname) is the
modification date,
> in seconds, of the file fname.
>
>   In bash I would do something like this :
>
>      stat -s fname
>      echo $st_mtime
>
>   so I tried the following :
>
>   let modification_date fname =
>     let chan=open_out "temp" in
>     let action1=Unix.system ("stat -s
"^fname) in
>     let action2=Unix.system ("echo
$st_mtime>temp ") in
>     Int64.of_string( input_line (open_in
"temp") );;
>
>  This doesn´t work (always raises the exception
"Failure int_of_string").
> Any suggestions ?

How about:

# let modification_date file = (Unix.stat
file).Unix.st_mtime;;
val modification_date : string -> float = <fun>

You could convert to Int64 if you wanted.

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scient
ists


------------------------ Yahoo! Groups Sponsor
--------------------~--> 
Yahoo! Groups gets a make over. See the new email design.
http://us.click.yahoo.com/XISQkA/lOaOAA/yQLSAA/saFolB/TM

------------------------------------------------------------
--------~-> 

Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http:/
/groups.yahoo.com/group/ocaml_beginners/

<*> To unsubscribe from this group, send an email to:
    ocaml_beginners-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 



"ocaml_beginners"::[] Modification date within Ocaml
user name
2006-06-24 14:01:04
   Yes, this is the right solution. Once again I browsed the
documentation
too fast ... Thanks !

                 Ewan



--- In ocaml_beginners@yahoogroups.com, Jon Harrop
<jon...> wrote:
> How about:
> 
> # let modification_date file = (Unix.stat
file).Unix.st_mtime;;
> val modification_date : string -> float =
<fun>
> 
> You could convert to Int64 if you wanted.
> 
> -- 
> Dr Jon D Harrop, Flying Frog Consultancy Ltd.
> Objective CAML for Scientists
> http://www.ffconsultancy.com/products/ocaml_for_scient
ists
>






------------------------ Yahoo! Groups Sponsor
--------------------~--> 
Great things are happening at Yahoo! Groups.  See the new
email design.
http://us.click.yahoo.com/TISQkA/hOaOAA/yQLSAA/saFolB/TM

------------------------------------------------------------
--------~-> 

Archives up to August 22, 2005 are also downloadable at http://www.connettivo.net/cntprojects/ocaml_beginners/
The archives of the very official ocaml list (the seniors'
one) can be found at http://caml.inria.fr
Attachments are banned and you're asked to be polite, avoid
flames etc. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http:/
/groups.yahoo.com/group/ocaml_beginners/

<*> To unsubscribe from this group, send an email to:
    ocaml_beginners-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.c
om/info/terms/
 



[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )