futimens()

set access and modification times for file 

Function


SYNOPSIS

#include <sys/stat.h>

int futimens(int fd, const struct timespec times[2]);


DESCRIPTION

The futimens() function sets the access and modification times of the named file with nanosecond resolution.

If times is NULL, the access and modification times of the file are set to the current time. The effective user ID of the process must match the owner of the file or the process must have write permission to the file or appropriate privileges to use futimens() in this way.

If times is not NULL, it is an array of timespec structures. The first array member specifies the access time, and the second array member specifies the modification time. Only the owner of the file and processes with appropriate privileges can use the futimens() function in this manner.

If the tv_nsec field of a timespec structure has the special value UTIME_NOW, the file's relevant timestamp shall be set to the greatest value supported by the file system that is not greater than the current time. If the tv_nsec field has the special value UTIME_OMIT, the file's relevant timestamp shall not be changed. In either case, the tv_sec field shall be ignored.


PARAMETERS

fd 

A file descriptor for the file which is to have its timestamps to be updated.

times 

Is the array that specifies the new access and modification times.


RETURN VALUES

If successful, futimens() returns a value of zero. On failure, it returns -1, does not change the file times, and sets errno to indicate the error:

EFAULT 

times is not NULL and is an invalid pointer.

EINTR 

A signal interrupted the call.

EPERM 

The process has insufficient permissions.

EROFS 

The file system that contains the file is mounted as read-only.


CONFORMANCE

POSIX.1 (2008)


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

Only the NTFS file system supports full file times. Refer to File Systems in the Windows Concepts chapter of the PTC MKS Toolkit UNIX to Windows Porting Guide.

On 8.1/2012R2/10/2016/2019/11/2022, you must be a member of the Backup Operators group (or have equivalent access rights) to modify the times on a directory.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
stat(), utime(), utimes()


PTC MKS Toolkit 10.4 Documentation Build 39.