Please enable JavaScript to view this site.

Updated August 2023

xcall MIAMEX, MX_FILETIMES, fspec, opcode {,status, mtime, ctime , atime, loc'rem}

MX_FILETIMES (MIAMEX 196) provides a way to set a file's last modification time (mtime), creation time (ctime), and/or last access time (atime). Setting the mtime of a file is equivalent in the Unix world to using the touch command on the file. For convenience, the function can also retrieve the file times, overlapping functionality already provided by MX_FILESTATS.

This function has both a subroutine and a print tab implementation.

Parameters

fspec  (String)  [in]

native or AMOS-style file specification of file

opcode (Num)  [in]

0 (mxop_get) to get the current times, 1 (mxop_set) to set them

status (Signed Num)  [out]

returns 0 for success, else an error code (file not found, etc.)

mtime, ctime, atime (T_FILETIME or B,6)  [in/out depending on opcode]

Unix-style file times, i.e. seconds since "the epoch" (midnight Jan 1, 1970). This is the same format as is used for MX_FILESTATS. When op = 1 (set), any time parameters either omitted or set to 0 will result in no change to the corresponding time attribute; -1 (or &hffffffff) may be used as a shortcut for the current time. See History note, below, for A-Shell 6.5.1740.

atime  (Num)  [in/out]

last access time (B6, I6 or F6 needed for 2038+)

loc'rec (String)  [in]

R=redirect to ATE; C=redirect to ATE, include cache search; L=local (default)

Notes

T_FILETIME and T_FILETIME48 are defined in ASHINC:TYPES.DEF as B,4 and B,6 respectively.
You can use the MX_FTFORMAT function to convert these time values to other formats.
To convert other time formats to the T_FILETIME format, you can use the SOSLIB function Fn'Date'Time'tO'FILETIME() function (fndatetime.bsi).
The operating system may impose limits and/or perform cleanup on your attempts to set file times. For example, in the Unix world, the ctime value isn't really the "creation" time but the time that the file's metadata was last changed, and there is no direct way to change it. However, changing either the mtime or atime will indirectly set the ctime to match.
Note that redirecting the operation to ATE requires ATE 6.5.1740.0+

Examples

Set the modification time of the file fspec$ to the current time. Note that the literal -1 will be auto-converted to the T_FILETIME (B,4) format:

xcall MIAMEX, MX_FILETIMES, fspec$, MXOP_SET, status, -1

Get the mtime and ctime and display the mtime in human readable form:

xcall MIAMEX, MX_FILETIMES, fspec$, MXOP_GET, status, mtime, ctime

xcall MIAMEX, MX_FTFORMAT, mtime, strtime$

? "Last mod time of ";fspec$;" was: ";strtime$

 

History

2023 August, A-Shell 6.5.1740:  Add support for additional timestamp bits (beyond 32) to resolve the Year 2038 problem. Note that you have to specify a parameter type capable of supporting more than 32 bits, e.g. B,6 or F6.

2023 August, A-Shell 6.5.1740:  Add support for last accessed time and ability to redirect operation to ATE

2019 November, A-Shell 6.5.1671:  Function added to A-Shell.

Created with Help+Manual 9 and styled with Premium Pack Version 5 © by EC Software