utimensat()
来源:互联网 发布:红包尾数控制软件 编辑:程序博客网 时间:2024/06/18 10:34
utimensat和futimens是以纳秒级的精度改变文件的时间戳,而utime和utimes是以微妙为时间精度的。
目录
- 1名称
- 2头文件
- 3相关函数
- 4描述
- 5返回值
- 6返回的错误类型
名称
编辑utimensat, futimens:以纳秒级的精度改变文件的时间戳
头文件
编辑#include <sys/stat.h>
相关函数
编辑int utimensat(int dirfd, const char *pathname,const struct timespectimes[2], intflags);
int futimens(int fd, const struct timespectimes[2]);
描述
编辑utimensat()通过文件的路径(pathname)获得文件,futimens()通过获得文件的句柄(fd)获得文件。
这两个系统调用函数都是通过一个时间数组times来改变时间戳的,times[0]修改最后一次访问的时间,times[1]修改最后修改的时间。该时间数组是由秒和纳秒两个部分组成,数据结构如下:
struct timespec {
time_t tv_sec; /* 秒 */
long tv_nsec; /* 纳秒 */
};
返回值
编辑调用成功,utimensat()和futimens()返回0,调用失败返回-1,并设置errno
返回的错误类型
编辑EACCES : 时间为空
EBADF:futimens()的文件句柄无效
EFAULT:times所指的地址空间无效
EINVAL:flags无效
EINVAL:pathname是空
ELOOP:utimensat()在需找pathname所指的路劲过程中有太多符号链接
ENAMETOOLONG:pathname太长
ENOENT:pathname指向了一个不存在的文件或者目录
ENOTDIR:pathname是一个相对路径,dirfd没有设置为AT_FDCWD或者文件描述符指向一个目录
EPERM:时间戳没有改为当前时间
EROFS:文件时只读文件
ESRCH:utimensat()的查找请求被拒绝
0 0
- utimensat()
- futimens,utimensat,utimes函数
- futimens, utimensat, and utimes Functions
- 射线和平面的相交性检测
- HDOJ 1004 Let the Balloon Rise
- 利用ExtJS实现:年级班级增删改查
- 用gcc-none-arm 编译出现undefined reference to `_sbrk'
- Oracle中Merge into用法总结
- utimensat()
- gulp入门2
- Linux多线程知识
- 如何压缩pdf文件 把pdf文件变小
- Android 5.1.1 源码目录结构
- String、StringBuffer、StringBuilder的比较
- C语言入门(十五)函数递归
- 【TJOI & HEOI 2016】【BZOJ 4554】【JZOJ 4612】 游戏
- 每日一练——判断两序列是否为同一二叉搜索树序列