Skip to Content
DocumentationAPI ReferenceWASIpath_filestat_set_times
WASIX / API REFERENCE

path_filestat_set_times()

Update time metadata on a file or directory.

Description

The path_filestat_set_times() function allows updating the time metadata (last accessed time and last modified time) for a file or directory specified by a path relative to the given directory.

On POSIX systems, a similar functionality is provided by the utimensat() function. It updates the timestamps (access time and modification time) of a file or directory with nanosecond precision.

Syntax

;;; Note: This is similar to `utimensat` in POSIX. ;;; Adjust the timestamps of a file or directory. (@interface func (export "path_filestat_set_times") (param $fd $fd) ;;; Flags determining the method of how the path is resolved. (param $flags $lookupflags) ;;; The path of the file or directory to operate on. (param $path string) ;;; 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))) )

Parameters

  • ctx: A mutable reference to the function environment.
  • fd: The file descriptor representing the directory that the path is relative to.
  • flags: Flags to control how the path is understood.
  • path: A wasm pointer to a null-terminated string containing the file path.
  • path_len: The length of the path string.
  • st_atim: The timestamp that the last accessed time attribute is set to.
  • st_mtim: The timestamp that the last modified time attribute is set to.
  • fst_flags: A bitmask controlling which attributes are set.

Return Value

The function returns an Errno value indicating the success or failure of the operation. If the operation is successful, it returns Errno::Success. Otherwise, it returns an appropriate Errno value.

Logging

This function has been instrumented with debug-level logging. It will log the following information:

  • %fd: The file descriptor representing the directory.
  • path: The path string.
  • %st_atim: The last accessed time attribute value.
  • %st_mtim: The last modified time attribute value.

Note

The path_filestat_set_times() function allows updating the time metadata (last accessed time and last modified time) for a file or directory specified by a path relative to the given directory. It checks if the specified directory has the necessary rights and updates the timestamps accordingly. On POSIX systems, a similar functionality is provided by the utimensat() function.