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/
|