The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

utime - set file access and modification times

 SYNOPSIS



#include <sys/types.h>
#include <utime.h>

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

 DESCRIPTION

The utime() function sets the access and modification times of the file named 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, times is interpreted as a pointer to a utimbuf structure and the access and modification times are set to the values contained in the designated structure. Only a process with effective user ID equal to the user ID of the file or a process with appropriate privileges may use utime() this way.

The utimbuf structure is defined by the header <utime.h>. The times in the structure utimbuf are measured in seconds since the Epoch.

Upon successful completion, utime() will mark the time of the last file status change, st_ctime, to be updated, see <sys/stat.h>.

 RETURN VALUE

Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error, and the file times will not be affected.

 ERRORS

The utime() function will fail if:
[EACCES]
Search permission is denied by a component of the path prefix; or the times argument is a null pointer and the effective user ID of the process does not match the owner of the file and write access is denied.
[ELOOP]
Too many symbolic links were encountered in resolving path.
[ENAMETOOLONG]
The length of the path argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}.
[ENOENT]
A component of path does not name an existing file or path is an empty string.
[ENOTDIR]
A component of the path prefix is not a directory.
[EPERM]
The times argument is not a null pointer and the calling process' effective user ID has write access to the file but does not match the owner of the file and the calling process does not have the appropriate privileges.
[EROFS]
The file system containing the file is read-only.

The utime() function may fail if:

[ENAMETOOLONG]
Pathname resolution of a symbolic link produced an intermediate result whose length exceeds {PATH_MAX}.

 EXAMPLES

None.

 APPLICATION USAGE

None.

 FUTURE DIRECTIONS

None.

 SEE ALSO

<sys/types.h>, <utime.h>.

DERIVATION

Derived from Issue 1 of the SVID.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]