4.2 文件函数

#include <sys/stat.h>
int stat(const char *restrict pathname, struct stat *restrict buf );
int fstat(int fd, struct stat *buf );
int lstat(const char *restrict pathname, struct stat *restrict buf );
int fstatat(int fd, const char *restrict pathname,
struct stat *restrict buf, int flag);
All four return: 0 if OK, −1 on error
  • 给出pathname,stat函数将与命名文件有关的信息结构
  • fstat 给出描述符fd上打开文件的文件信息
  • lstat 给出符号链接信息,而不是符号链接所连接文件信息

4.15 link

#include <unistd.h>
int link(const char *existingpath, const char *newpath);
* newpath 引用 existpath文件
int linkat(int efd, const char *existingpath, int nfd, const char *newpath,int flag);
* 两个路径名任意相对,则相对fd计算文件位置
* 两个描述符任一设置为AT_FDCWD,相对于当期目计算文件位置
flag 控制连接连接文件的源文件还是连接符本身
AT_SYMLINK_FOLLOW 连接符号连接的文件本身
Both return: 0 if OK, .1 on error
#include <unistd.h>
int unlink(const char *pathname);
int unlinkat(int fd, const char *pathname, int flag);
Both return: 0 if OK, .1 on error
#include <stdio.h>
int remove(const char *pathname);
Returns: 0 if OK, .1 on error

APUE第4章 文件和目录的更多相关文章

  1. apue 第4章 文件和目录

    获取文件属性 #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> int stat(c ...

  2. 零基础学Python--------第10章 文件及目录操作

    第10章 文件及目录操作 10.1 基本文件操作 在Python中,内置了文件(File)对象.在使用文件对象时,首先需要通过内置的open() 方法创建一个文件对象,然后通过对象提供的方法进行一些基 ...

  3. apue学习笔记(第四章 文件和目录)

    本章将描述文件系统的其他特性和文件的性质. 函数stat.fstat.fstatat和lstat #include <sys/stat.h> int stat(const char *re ...

  4. 《UNIX环境高级编程》(APUE) 笔记第四章 - 文件和目录

    4 - 文件和目录 1. 函数 stat.fstat.fstatat 和 lstat #inlcude <sys/stat.h> int stat(const char *restrict ...

  5. UNIX环境高级编程 第4章 文件和目录

    第三章说明了关于文件I/O的基本函数,主要是针对普通regular类型文件.本章描述文件的属性,除了regular文件还有其他类型的文件. 函数stat.fstat.fstatat和lstat sta ...

  6. APUE(4)---文件和目录 (3)

    十三.函数rename和renameat #include <stdio.h> int rename(const char *oldname, const char *newname); ...

  7. APUE(4)---文件和目录 (2)

    七.函数umask umask函数为进程设置文件模式创建屏蔽字,并返回之前的值,这是少数几个没有出错返回函数中的一个.其中cmask是9个常量(S_IR/W/XUSR.S_IR/W/XGRP.S_IR ...

  8. APUE学习笔记3——文件和目录

    1 简介 之前学习了执行I/O操作的基本函数,主要是围绕普通文件I/O的打开.读或写.下面继续学习Unix文件系统的其他特征和文件的基本性质.我们将从stat函数开始,了解stat结构所代表的文件属性 ...

  9. Linux命令应用大词典-第 15章 文件、目录权限和属性

    15.1 chmod:更改文件和目录的模式 15.2 chown:更改文件和目录的用户所有者和组群所有者 15.3 chgrp:更改文件或目录的所属组 15.4 umask:显示和设置文件及目录创建默 ...

随机推荐

  1. SDS查看部署在集成TOMCAT服务器中的项目目录结构

  2. [物理学与PDEs]第1章习题参考解答

    [物理学与PDEs]第1章习题1 无限长直线的电场强度与电势 [物理学与PDEs]第1章习题2 均匀带电球面的电场强度与电势 [物理学与PDEs]第1章习题3 常场强下电势的定解问题 [物理学与PDE ...

  3. Carath\'eodory 不等式

    (Carath\'eodory 不等式) 利用 Scharwz 引理及线性变换, 证明: 若函数 $f(z)$ 在圆 $|z|<R$ 内全纯, 在 $|z|\leq R$ 上连续, $M(r)$ ...

  4. 火狐firefox提示“内容编码错误 无法显示您尝试查看的页面,因为它使用了无效或者不支持的压缩格式。”

    火狐firefox浏览器打开网也是时提示“内容编码错误 无法显示您尝试查看的页面,因为它使用了无效或者不支持的压缩格式.” 今早一来打开用PHPCMS做的网站时就提示这个错误,用其他浏览器打开提示的是 ...

  5. Navicat MySQL连接Linux下MySQL的问题解决方案

    Error1: 2003:Can't connect to MySQL server on 'localhost' 解决方法:关闭Linux的防火墙功能. #chkconfig iptables of ...

  6. 跨域请求 & jsonp

    0 什么是跨域请求 在一个域名下请求另外一个域名下的资源,就是跨域请求.example 1:比如:我当前的域名是http://che.pingan.com.我现在要去请求http://www.cnbl ...

  7. CentOS7 备忘录

    //安装CentOS7 1.用LinuxLive USB Creator,LiveUSB Creator设置U盘安装不成功,UltraISO可以. 2.旧电脑(x8le)安装时报"/dev/ ...

  8. [Flex] ButtonBar系列——flex3 labelFunction用户提供的函数,在每个项目上运行以确定其标签

    <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="h ...

  9. PS 查看选定图层的高宽

    1.    选中图层,然后按键盘"Ctrl+T(菜单中点编辑->自由变换)",然后上面工具条会出现调整比率,宽W:100% H:100%,然后在100%的位置点鼠标右键,选择 ...

  10. (medium)LeetCode 210.Course Schedule II

    There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prer ...