utime

Sets file access and modification times.

Library:LibC
Classification:POSIX
Service:File and Directory I/O

Syntax

  #include <utime.h> 
   
  int   utime (
     const char             *path,
     const struct utimbuf   *times);
  

Parameters

path

(IN) Points to a string containing the path of the file for which access and modification times are to be set.

times

(IN) Points to a utimbuf structure containing the time values. If times is a NULL pointer, the times are set to the current time.

Return Values

If successful, returns 0. Otherwise, does not change the file times, returns -1, and sets errno to one of the following values:

Decimal

Constant

Description

1

ENOENT

A component specified in the path does not exist or the path is an empty string.

6

EACCES

The caller has insufficient rights.

62

EBUSY

The specified file is in use.

65

ENAMETOOLONG

The length of the path argument exceeds the maximum path length, or a pathname component is longer than maximum name length.

67

ENOTDIR

A component specified in the path is not a directory.

69

EPERM

The caller has insufficient rights.

76

EROFS

The specified directory entry is part of a read-only file system.

Remarks

The caller must have the necessary rights to successfully modify the file's access or modification time.

If the path parameter specifies a directory, the modification time and date are updated and the last accessed date is ignored (because directories do not have a last accessed date).

The modification time is taken from the modtime field in the utimbuf structure, and the last accessed date is taken from the actime field.

DOS has no notion of “accessed time.” Therefore when time is being set on the DOS partition, the value in the actime field is undefined, and only the modtime field is used.

See Also

stat