日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux服务器编程之:utime()函数

發(fā)布時間:2024/9/27 linux 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux服务器编程之:utime()函数 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1.依賴的頭文件

#include<sys/types.h>

#include<utime.h>

2函數(shù)聲明

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

#include<sys/time.h>

int utimes(const char *filename,const struct timeval times[2]);

函數(shù)說明:

The? utime()? system? call changes the access and modification times of
?????? the inode specified by filename to the actime? and? modtime? fields? of
?????? times respectively.

???????翻譯:調(diào)用utime來修改inode中的信息,傳遞的值有:文件名,訪問時間和更改時間。

If? times? is? NULL, then the access and modification times of the file
?????? are set to the current time.

??????翻譯:如果時間為NULL,訪問時間和修改時間默認(rèn)設(shè)置成了當(dāng)前時間。


??????成功放回0,失敗返回1

3.下面是????utimbuf這個結(jié)構(gòu)體:

?????struct utimbuf

???? {

????????????? time_t atime;????????? /*access time :訪問時間*/

??????????????time_t modtime;???? /*modification time :?更改時間*/

?????};

4.utimes()調(diào)用也

The utimes() system call is similar, but the times argument? refers? to
?????? an? array? rather? than? a? structure.?? The elements of this array are
?????? timeval structures, which allow a precision of 1 microsecond for speci‐
?????? fying timestamps.? The timeval structure is:

?????????? struct timeval {
?????????????? long tv_sec;??????? /* seconds */
?????????????? long tv_usec;?????? /* microseconds */
?????????? };

?????? times[0]? specifies the new access time, and times[1] specifies the new
?????? modification time.? If times is NULL, then analogously to utime(),? the
?????? access and modification times of the file are set to the current time.

utimes()的調(diào)用也相似,但是這個時間指定的是一個數(shù)組,而不是一個結(jié)構(gòu)體,數(shù)組的每個元素師一個timeval結(jié)構(gòu)體

這個結(jié)構(gòu)體中允許一個為timestamps所用的精確的微秒值(微秒,百萬分之一秒),其中timeval結(jié)構(gòu)體如下:

???????struct timeval

?????? {

???????????? long tv_sec;????????? /*seconds?秒*/

?????????????long tv_usec;????????/*microseconds?微秒,百萬分之一秒*/

?????? }

times[0]這個元素指定的是訪問時間,times[1]指定的是修改時間。如果時間為NULL,那么,類似(analogously)utime(),

訪問時間和修改時間被設(shè)置成當(dāng)前時間。










總結(jié)

以上是生活随笔為你收集整理的Linux服务器编程之:utime()函数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。