utime()

set access and modification times for file 

Function


SYNOPSIS

#include <sys/types.h>

#include <utime.h>

int utime(const char *pathname, const struct utimbuf *times);


DESCRIPTION

The utime() function sets the access and modification times of the named file.

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 utime() in this way.

If times is not NULL, it is interpreted as a pointer to a utimbuf structure; and the access and modification times are set to the values in the designated structure. Only the owner of the file and processes with appropriate privileges can use the utime() function in this manner.


PARAMETERS

pathname 

Points to a path name that names a file.

times 

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


RETURN VALUES

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

EACCES 

A component of the pathname prefix denies search permission.

EFAULT 

pathname is an invalid pointer, or times is not NULL and is an invalid pointer.

EINTR 

A signal interrupted the call.

ENAMETOOLONG 

The length of the pathname parameter exceeds PATH_MAX or a pathname component is longer than NAME_MAX.

ENOENT 

The named file does not exist or pathname points to an empty string.

ENOTDIR 

A component of the pathname prefix is not a directory.

EPERM 

The process has insufficient permissions.

EROFS 

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


CONFORMANCE

POSIX.1 (1996).


MULTITHREAD SAFETY LEVEL

Async-signal-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:
futimens(), stat(), utimes()


PTC MKS Toolkit 10.4 Documentation Build 39.