Re: file date [message #10343 is a reply to message #10334] |
Wed, 19 November 1997 00:00  |
Christian Soeller
Messages: 46 Registered: August 1996
|
Member |
|
|
Martin Schultz <mgs@io.harvard.edu> writes:
>
> Hi,
>
> is there any way to figure out the modification date of a given file in
> IDL ? I searched the manual but couldn't find anything. Unfortunately
> there is no such field in FSTAT. What I am trying to do is put together
> a small utitlity which would perform semi-automatic updates of my
> website library. Has anyone done such things before ?
>
I am not aware of a function inside idl that would do this. However, if
you're on a unix system you should have the 'stat' command somewhere that,
on my system, prints the file modification time in seconds since 1970
if invoked as
stat -mq filename
So all you have to do inside idl is
function modtime, filename
exists = findfile(filename)
if (exists(0) eq '') then message, 'file '+filename+' not found'
spawn, 'stat -mq '+filename, mtime
return, long(mtime)
end
For other invocations of stat see 'man stat'. The only drawback doing it
like this is the 'bizarre' signal handling of IDL that can cause
'spawn' to hang (at least that was true with IDL4X). If you have no fear
of C coding you could code a stat system call in C and pass the field(s)
your interested in with a home built routine using 'call_external'.
Hope this helps,
Christian
------------------------------------------------------------ --------
Christian Soeller mailto: csoelle@sghms.ac.uk
St. Georges Hospital Medical School Dept. of Pharmacology
Cranmer Terrace London SW17 0RE
|
|
|