C language Utime () function: Modify file access time and change time
header file:
#include <sys/types.h> #include <utime.h>
To define a function:
int utime (const char * filename, struct utimbuf * buf);
Function Description: Utime () is used to modify the Inode access time that the parameter filename file belongs to. The structure UTIMBUF is defined as follows:
struct Utimbuf
{
time_t actime;
time_t modtime;
};
Return value: If the parameter buf is a null pointer (NULL), the access time and the change time of the file are all set to the current time ... Successful execution returns 0, failure returns-1, and the error code is stored in errno.
Error code:
1, eaccess access to the file is denied, insufficient permissions.
2, enoent specified file does not exist.
C language Utimes () function: Modify file access time and change time
header file:
#include <sys/types.h> #include <utime.h>
To define a function:
int utimes (char * filename, struct timeval *TVP);
Function Description: Utimes () is used to modify the Inode access time and modification time of the parameter filename file. The structure timeval is defined as follows:
struct Timeval
{
long tv_sec;
Long tv_usec; Subtlety
};
Return value: Parameter TVP points to two timeval structural spaces, compared to the UTIMEBUF structure used by Utime (), tvp[0].tc_sec to Utimbuf.actime, tvp[1].tv_sec to Utimbuf.modtime. Successful execution returns 0. Failure returns-1, error generation
The code is stored in the errno.
Error code:
1, eaccess access to the file is denied, insufficient permissions.
2, enoent specified file does not exist.