Each file has three timestamps associated with it: its access time,
its modification time, and its attribute modification time. These
correspond to the
members of the
stat structure; see section File Attributes.
All of these times are represented in calendar time format, as
time_t objects. This data type is defined in `time.h'.
For more information about representation and manipulation of time
values, see section Calendar Time.
Reading from a file updates its access time attribute, and writing updates its modification time. When a file is created, all three timestamps for that file are set to the current time. In addition, the attribute change time and modification time fields of the directory that contains the new entry are updated.
Adding a new name for a file with the
link function updates the
attribute change time field of the file being linked, and both the
attribute change time and modification time fields of the directory
containing the new name. These same fields are affected if a file name
is deleted with
a file with
rename affects only the attribute change time and
modification time fields of the two parent directories involved, and not
the times for the file being renamed.
Changing attributes of a file (for example, with
its attribute change time field.
You can also change some of the timestamps of a file explicitly using
utime function--all except the attribute change time. You
need to include the header file `utime.h' to use this facility.
utimbufstructure is used with the
utimefunction to specify new access and modification times for a file. It contains the following members:
If times is a null pointer, then the access and modification times
of the file are set to the current time. Otherwise, they are set to the
values from the
modtime members (respectively)
utimbuf structure pointed at by times.
The attribute modification time for the file is set to the current time in either case (since changing the timestamps is itself a modification of the file attributes).
utime function returns
0 if successful and
on failure. In addition to the usual file name errors
(see section File Name Errors), the following
errno error conditions
are defined for this function:
Each of the three time stamps has a corresponding microsecond part,
which extends its resolution. These fields are called
each has a value between 0 and 999,999, which indicates the time in
microseconds. They correspond to the
tv_usec field of a
timeval structure; see section High-Resolution Calendar.
utimes function is like
utime, but also lets you specify
the fractional part of the file times. The prototype for this function is
in the header file `sys/time.h'.
tvp, and the new modification time by
tvp. This function comes from BSD.
The return values and error conditions are the same as for the
Go to the first, previous, next, last section, table of contents.