Advanced Programming in UNIX Environment Episode 17

前端之家收集整理的这篇文章主要介绍了Advanced Programming in UNIX Environment Episode 17前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

rename和renameat函数

  1. #include <stdio.h>
  2.  
  3. int rename(const char *oldname,const char *newname);
  4. int renameat(int oldfd,const char *oldname,int newfd,const char *newname);

引入符号链接的原因是为了避开硬链接的一些限制。

  1. #include <unistd.h>
  2.  
  3. int symlink(const char *actualpath,const char *sympath);
  4. int symlinkat(const char *actualpath,int fd,const char *sympath);

打开该链接本身,并读取该链接中的名字。readlink和readlinkat函数提供了这种功能

  1. #include <unistd.h>
  2.  
  3. ssize_t readlink(const char *restrict pathname,char *restrict buf,size_t bufsize);
  4. ssize_t readlinkat(int fd,const char *restrict pathname,size_t bufsize);

futimens和utimensat函数可以指定纳秒级精度的时间戳。

  1. #include <unistd.h>
  2.  
  3. int futimes(int fd,const struct timespec times[2]);
  4. int utimensat(int fd,const char *path,const struct timespec times[2],int flag);

futimes和utimensat函数都包含在POSIX.1中,第3个函数utimes包含在Single UNIX Specification的XSI扩展中。

  1. #include <sys/time.h>
  2.  
  3. int utimes(const char *pathname,const struct timeval times[2])

猜你在找的Bash相关文章