我是靠谱客的博主 高高狗,这篇文章主要介绍程序4-6 utime函数实例,现在分享给大家,希望可以做个参考。

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
1 //http://blog.chinaunix.net/uid-24549279-id-71355.html 2 /* 3 ============================================================================ 4 Name : test.c 5 Author : blank 6 Version : 7 Copyright : Your copyright notice 8 Description : 程序4-6 utime函数实例 9 ============================================================================ 10 */ 11 12 #include <fcntl.h> 13 #include <utime.h> 14 #include <sys/stat.h> 15 #include "ourhdr.h" 16 17 int main(int argc, char *argv[]) 18 { 19 int i, fd; 20 struct stat statbuf; 21 struct utimbuf timebuf; 22 23 for (i=1; i<argc; i++){ 24 printf("argv[%d] = %sn", i, argv[i]); 25 if (stat(argv[i], &statbuf) < 0){//fetch current times 26 err_ret("%s: stat error", argv[1]); 27 continue; 28 } 29 30 if ((fd = open(argv[1], O_RDWR|O_TRUNC)) < 0){ 31 err_ret("%s: open error", argv[1]); 32 continue; 33 } 34 35 close(fd); 36 timebuf.actime = statbuf.st_atim.tv_sec; 37 timebuf.modtime = statbuf.st_mtim.tv_sec; 38 if (utime(argv[i], &timebuf) < 0){ 39 // retset time 40 err_ret("%s: utime error", argv[i]); 41 continue; 42 } 43 } 44 }

 

转载于:https://www.cnblogs.com/blankqdb/p/3700363.html

最后

以上就是高高狗最近收集整理的关于程序4-6 utime函数实例的全部内容,更多相关程序4-6内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(109)

评论列表共有 0 条评论

立即
投稿
返回
顶部