1.依赖的头文件

#include<sys/types.h>

#include<utime.h>

2函数声明

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

#include<sys/time.h>

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

函数说明:

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.

翻译:调用utime来修改inode中的信息,传递的值有:文件名,访问时间和更改时间。

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

翻译:如果时间为NULL,访问时间和修改时间默认设置成了当前时间。

成功放回0,失败返回1

3.下面是    utimbuf这个结构体:

struct utimbuf

{

time_t atime;          /*access time :访问时间*/

time_t modtime;     /*modification time : 更改时间*/

};

4.utimes()调用也

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()的调用也相似,但是这个时间指定的是一个数组,而不是一个结构体,数组的每个元素师一个timeval结构体

这个结构体中允许一个为timestamps所用的精确的微秒值(微秒,百万分之一秒),其中timeval结构体如下:

struct timeval

{

long tv_sec;          /*seconds 秒*/

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

}

times[0]这个元素指定的是访问时间,times[1]指定的是修改时间。如果时间为NULL,那么,类似(analogously)utime(),

访问时间和修改时间被设置成当前时间。



Linux服务器编程之:utime()函数相关推荐

  1. linux读取文件修改时间函数,Linux服务器编程之utime()函数修改文件存取时间

    Linux服务器编程之utime()函数修改文件存取时间 C语言utime()函数:修改文件的存取时间和更改时间 头文件: #include #include 定义函数: int utime(cons ...

  2. linux网络编程之Listen函数参数介绍

    1.listen()函数介绍 listen函数使用主动连接套接口变为被连接套接口,使得一个进程可以接受其它进程的请求,从而成为一个服务器进程.在TCP服务器编程中listen函数把进程变为一个服务器, ...

  3. Linux服务器编程之:link()函数,ln命令,symlink,readlink,案例说明

    1 link()依赖头文件 #include<unistd.h> 2函数定义 int link(const char *oldpath,const char *newpath); 函数说明 ...

  4. Linux服务器编程之:truncate()函数+案例说明

    1.依赖头文件 #include<unistd.h> #include<sys/types.h> 2.函数定义: int truncate(const char *path,o ...

  5. Linux服务器编程之:chown()函数,chown命令

    1.依赖的头文件 #include<unistd.h> 2.函数定义: //通过传入path的方式,改变和文件的拥有关系,如果他是一个符号链接,则跟踪它 int chown(const c ...

  6. linux chown 函数用噶,Linux服务器编程之:chown()函数,chown命令

    1.依赖的头文件 #include 2.函数定义: //通过传入path的方式,改变和文件的拥有关系,如果他是一个符号链接,则跟踪它 int chown(const char *path, uid_t ...

  7. linux ioctl网络参数设置,Linux 网络编程之ioctl函数

    1.介绍 Linux网络程序与内核交互的方法是通过ioctl来实现的,ioctl与网络协议栈进行交互,可得到网络接口的信息,网卡设备的映射属性和配置网络接口.并且还能够查看,修改,删除ARP高速缓存的 ...

  8. Linux 应用编程之stat 函数

    Linux 下可以使用 stat 命令查看文件的属性,其实这个命令内部就是通过调用 stat()函数来获取文件属性的,stat 函数是 Linux 中的系统调用,用于获取文件相关的信息.(可通过&qu ...

  9. Linux应用编程之dup函数和dup2函数

    在 Linux 系统中,open 返回得到的文件描述符 fd 可以进行复制,复制成功之后可以得到一个新文件描述符,使用新的文件描述符和旧的文件描述符都可以对文件进行 IO 操作,复制得到的文件描述符和 ...

最新文章

  1. 博客 | Machine Learning Yearning 要点笔记
  2. SAP PR 转 PO
  3. sql已经完成,生成表
  4. Project Euler Problem 9-Special Pythagorean triplet
  5. docker学习笔记(一)docker入门
  6. python 判断时间是否大于6点_python - 在dataframe中,如何检查时间增量是否大于一分钟?_pandas_酷徒编程知识库...
  7. GetCommandLineW()作用
  8. 获取小程序 openid
  9. Goodfellow“死磕”NIPS:这名字涉及色情和仇日
  10. 调整jvm参数_JVM源码分析之MetaspaceSize和MaxMetaspaceSize的区别
  11. 手机android系统安装,如何重新安装Android手机系统
  12. 电大本科计算机科学与技术,中央电大开放本科计算机科学与技术专业微计算机技术试题_0701...
  13. 最新电脑cpu性能排行服务器,服务器cpu性能排行,教您服务器cpu性能排行
  14. 美团点评数据平台融合实践
  15. ESP8266 下 OTA 更新 Firmware 和FileSystem
  16. Matlab代码区出现中文乱码的情况
  17. Ae试水~(待填坑)
  18. 绿色版Mysql的安装配置
  19. PCB之AD快速布局
  20. 分享优质JAVA学习网站

热门文章

  1. wxWidgets:编写一个应用程序- 使用 WxTextCtrl
  2. wxWidgets:wxTextCompleterSimple类用法
  3. wxWidgets:wxSpinCtrl类用法
  4. wxWidgets:wxSearchCtrl类用法
  5. boost::hana::hash用法的测试程序
  6. boost::hana::drop_front用法的测试程序
  7. bgi::detail::intersection_content用法的测试程序
  8. boost::dynamic_bitset模块的测试程序
  9. boost的chrono模块线程时钟的测试程序
  10. Boost:双图bimap与property地图的测试程序