Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

utime, utime64 - set file access and modification times

&pagelevel(4)&pagelevel

Syntax

#include <utime.h>

Optional
#include <sys/types.h> (End)

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

CRTE111A30
int utime64(const char *path, const struct utimbuf64 *times); (End)

Description

utime() sets the access and modification times of the file specified by the path argument.

If times is a null pointer, 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 have appropriate privileges to use utime() in this manner.

If times is not a null pointer, then times is interpreted as a pointer to a utimbuf structure, and the access and modification times are set to the values contained in this structure. Only a process with an effective user ID that matches the file ́s owner or a process with appropriate privileges may use utime() this way.

The times in the structure utimbuf are measured in seconds since
00:00:00 GMT, January 1, 1970 (see utime.h).

Upon successful completion, utime() marks the time of the last change to the file, st_ctime, for update (see sys/stat.h).

The function utime64() behaves like the function utime(), except that it uses the structure utimbuf64 instead of the structure utimbuf and therefore can process timestamps beyond 01/19/2038 03:14:07 UTC.

The structure utimbuf contains the following components:

time_t actime;        /* access time */
time_t modtime;       /* modification time */

The structure utimbuf64 contains the following components:

time64_t actime;        /* access time */
time64_t modtime;       /* modification time */

Return val.

0

if successful.


-1

if an error occurs. errno is set to indicate the error.

Errors

utime() and utime64() will fail if:

 

EACCES

Search permission is denied for a component of the path; or the effective user ID does not match that of a system administrator or the owner of the file, times is a null pointer, and write access is denied.

 

Extension

 

EFAULT

times is not null and points outside the allocated space of the process
or path points outside the allocated space of the process.

 

EINTR

A signal was caught during the system call utime() resp. utime64().

 

EINVAL

An attempt was made to access a BS2000 file.

 

ELOOP

Too many symbolic links were encountered in resolving path. (End)

 

ENAMETOOLONG  

 


The length of path exceeds {PATH_MAX} or the length of a component of path exceeds{NAME_MAX}.


ENOENT

The named file does not exist.


ENOTDIR

A component of the path is not a directory.


EPERM

The effective user ID does not match that of a system administrator or the owner of the file and times is a null pointer.


EROFS

The file system containing the file is mounted as a read-only file system.


utime64() fails when the following applies:

 

ENOSYS

POSIX-BC correction status < A47.

Notes

utime() and utime64() are executed only for POSIX files.

See also

stat(), sys/types.h, utime.h.