Expand/Shrink

get_file_date

Definition: object res = get_file_date(string filename, integer date_type=D_MODIFICATION)
Description: filename: the name of the file to query
date_type: one of D_CREATION, D_LASTACCESS, or D_MODIFICATION.
pwa/p2js: Not supported.
Notes: Returns the creation, last access, or last modification date, [DT_YEAR..DT_SECOND] format, or -1 if the file details could not be retrieved. Should you need further clarification (specifically the precise conditions under which last access changes, which may for performance reasons be set to, say, max once per day, or never) please refer to your operating/file system documentation. I know for a fact there are subtle differences between FAT and NTFS file systems on windows, let alone any differences between windows and linux.

There is also a matching object res = set_file_date(string filename, integer date_type=D_MODIFICATION) function that, obviously enough, allows you to set a specific file date to the current date, returning true when it succeeds without error, otherwise an error string - see builtins/pfile.e for the full set. On linux date_type is ignored, both the last access and modification dates are set (as per touch), and the result is just false on error (ie non-existing/read-only/no-write-permission files). As above you should not assume the consequences will be second-perfect, or indeed have any affect whatsoever - and that is pretty much completely out of my hands, but basically matches, say, libc.
Example:
sequence last_mod = get_file_date(filename)
atom delta = timedate_diff(last_mod,date())
printf(1,"File %s last downloaded %s ago.\n",{filename,elapsed(delta)})
Implementation: See builtins\pfile.e (an autoinclude) for details of the actual implementation.
See Also: dir, date, timedate_diff, elapsed
Expand/Shrink