|This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.|
Set a file's access and modification times
#include <sys/time.h> int utimes( const char * __path, const struct timeval * __times );
- The name of the files whose times you want to set.
- NULL, or an array of timeval structures:
- The first array member represents the date and time of last access.
- The second member represents the date and time of last modification.
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The utimes() function sets the access and modification times of the file pointed to by the __path argument to the value of the __times argument. This function allows time specifications accurate to the microsecond.
The times in the timeval structure are measured in seconds and microseconds since the Unix Epoch (00:00:00 January 1, 1970 Coordinated Universal Time (UTC)), although rounding toward the nearest second may occur.
If the __times argument is NULL, the access and modification times of the file are set to the current time. The effective user ID of the process must be the same as the owner of the file, or must have write access to the file or superuser privileges to use this call in this manner. On completion, utimes() marks the time of the last file status change, st_ctime, for update.
- An error occurred (errno is set).
- Search permission is denied by a component of the path prefix; or the __times argument is NULL and the effective user ID of the process doesn't match the owner of the file and write access is denied.
- The __path or __times argument points to an illegal address.
- A signal was caught during the utimes() function.
- The number of microseconds specified in one or both of the timeval structures pointed to by __times was greater than or equal to 1,000,000 or less than 0.
- An I/O error occurred while reading from or writing to the filesystem.
- Too many symbolic links were encountered in resolving __path.
- Components of __path require hopping to multiple remote machines and the filesystem doesn't allow it.
- The length of the __path argument exceeds PATH_MAX or a pathname component is longer than NAME_MAX.
- The __path argument points to a remote machine and the link to that machine is no longer active.
- A component of __path doesn't name an existing file or __path is an empty string.
- A component of the path prefix isn't a directory.
- The __times argument isn't NULL and the calling process's effective user ID has write access to the file but doesn't match the owner of the file, and the calling process doesn't have the appropriate privileges.
- The filesystem containing the file is read-only.
- Path name resolution of a symbolic link produced an intermediate result whose length exceeds PATH_MAX.