Set timestamp metadata on a file.
fd_filestat_set_times() function is used to set the timestamp metadata on a file identified by a file descriptor. It allows modifying the last accessed time (
st_atim) and last modified time (
st_mtim) of the file. The function also provides a bit-vector (
fst_flags) to control which times should be set.
In POSIX systems, files have associated timestamp metadata that stores information about the file's access and modification times. The
fd_filestat_set_times() function enables applications to update these timestamps. It allows setting the last accessed and last modified times to specific values or using the current time.
;;; Note: This is similar to `futimens` in POSIX. ;;; Adjust the timestamps of an open file or directory. (@interface func (export "fd_filestat_set_times") (param $fd $fd) ;;; The desired values of the data access timestamp. (param $atim $timestamp) ;;; The desired values of the data modification timestamp. (param $mtim $timestamp) ;;; A bitmask indicating which timestamps to adjust. (param $fst_flags $fstflags) (result $error (expected (error $errno))) )
ctx: A mutable reference to the function environment.
fd: The file descriptor of the file to set the timestamp metadata.
st_atim: The last accessed time to set.
st_mtim: The last modified time to set.
fst_flags: A bit-vector that controls which times to set.
The function returns an
Errno value indicating the success or failure of the operation.
This function has been instrumented with debug-level logging. It will log the following information:
%fd: The file descriptor being modified.
%st_atim: The last accessed time being set.
%st_mtim: The last modified time being set.
fd_filestat_set_times() function allows setting the timestamp metadata of a file identified by the provided file descriptor. Applications can specify the last accessed and last modified times using the provided parameters. The
fst_flags bit-vector is used to control which times should be set.
Please note that if both
SET_ATIM_NOW flags are set, or if both
SET_MTIM_NOW flags are set in
fst_flags, the function will return