程序4-6 utime函数实例
//http://blog.chinaunix.net/uid-24549279-id-71355.html
/*
============================================================================
Name : test.c
Author : blank
Version :
Copyright : Your copyright notice
Description : 程序4-6 utime函数实例
============================================================================
*/ #include <fcntl.h>
#include <utime.h>
#include <sys/stat.h>
#include "ourhdr.h" int main(int argc, char *argv[])
{
int i, fd;
struct stat statbuf;
struct utimbuf timebuf; for (i=; i<argc; i++){
printf("argv[%d] = %s\n", i, argv[i]);
if (stat(argv[i], &statbuf) < ){//fetch current times
err_ret("%s: stat error", argv[]);
continue;
} if ((fd = open(argv[], O_RDWR|O_TRUNC)) < ){
err_ret("%s: open error", argv[]);
continue;
} close(fd);
timebuf.actime = statbuf.st_atim.tv_sec;
timebuf.modtime = statbuf.st_mtim.tv_sec;
if (utime(argv[i], &timebuf) < ){
// retset time
err_ret("%s: utime error", argv[i]);
continue;
}
}
}
程序4-6 utime函数实例的更多相关文章
- 程序清单 8-8 exec函数实例,a.out是程序8-9产生的可执行程序
/* ============================================================================ Name : test.c Author ...
- 文件和目录之utime函数
一个文件的访问和修改时间可以用utime函数更改. #include <utime.h> int utime( const char *pathname, const struct uti ...
- 程序4-4 chmod函数实例
//http://blog.chinaunix.net/uid-24549279-id-71355.html /* ========================================== ...
- 程序4-3 umask函数实例
//http://blog.chinaunix.net/uid-24549279-id-71355.html /* ========================================== ...
- 程序4-2 access函数实例
//http://blog.chinaunix.net/uid-24549279-id-71355.html /* ========================================== ...
- utime函数
utime函数:对一个文件的访问和修改时间 #include <utime.h> int utime( const char *pathname, const struct utimbuf ...
- python迭代器与iter()函数实例教程
python迭代器与iter()函数实例教程 发布时间:2014-07-16编辑:脚本学堂 本文介绍了python迭代器与iter()函数的用法,Python 的迭代无缝地支持序列对象,而且它还允许程 ...
- 解决C#程序只允许运行一个实例的几种方法详解
解决C#程序只允许运行一个实例的几种方法详解 本篇文章是对C#中程序只允许运行一个实例的几种方法进行了详细的分析介绍,需要的朋友参考下 本文和大家讲一下如何使用C#来创建系统中只能有该程序的一个实例运 ...
- UNIX环境编程学习笔记(11)——文件I/O之文件时间以及 utime 函数
lienhua342014-09-16 1 文件的时间 每个文件都有三个时间字段,如表 1 所示. 表 1: 文件的三个时间字段 说明 字段 st_atime 文件数据的最后访问时间 st_mtime ...
随机推荐
- Android DiskLruCache 硬盘缓存
概述 记得在很早之前,我有写过一篇文章Android高效加载大图.多图解决方案,有效避免程序OOM,这篇文章是翻译自Android Doc的,其中防止多图OOM的核心解决思路就是使用LruCache技 ...
- HorizontalScrollView实现先左滑动后右滑动动画
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); s ...
- 【读书笔记】iOS-GCD-block
一,block的定义 //申明变量 (void)(^PrintStr)(void); //定义 PrintStr=^{ NSLog(@"PrintStr"); }; //调用 Pr ...
- UITableView删除添加和移动
#import "RootTableViewController.h" @interface RootTableViewController () @property (nonat ...
- iOS之 Mac下抓包工具使用wireshark
主要是mac上面网卡的授权 分三个步骤: 1.wireshark安装 wireshark运行需要mac上安装X11,mac 10.8的系统上默认是没有X11的.先去http://x ...
- LeetCode 4 Median of Two Sorted Arrays (两个数组的mid值)
题目来源:https://leetcode.com/problems/median-of-two-sorted-arrays/ There are two sorted arrays nums1 an ...
- nginx安装过程,报错处理:make[1]: *** [objs/addon/src/bson.o] Error 1
nginx安装过程中,经常会有各种错误: 具体安装步骤这里不做说明,网上一搜大把: 主要分析安装过程中遇到的问题 在make编译的时候,若报如下错误: cc1: warnings being trea ...
- img标签使用默认图片的一种方式
基于html5提供的onerror这个时间属性.
- Eclipse 一直提示 loading descriptor for 的解决方法
启动eclipse之后,进行相关操作时,弹出界面,提示:loading descriptor for xxx 解决方法: 在Eclipse左侧的Project Explorer 最右上角有一个小钮,鼠 ...
- 【mysql】使用tpcc-mysql进行压力测试
Tpcc-mysql是percona基于tpcc衍生出来专用于mysql基准测试的产品 ,可以参见 <高性能MySQL第三版> 一.安装 rpm -Uvh http://dl.fedora ...