Linux的基本文件操作函数

    Linux通过相应的对文件的IO函数来实现对文件的操作,这些函数通常被称作“不带缓冲的IO”,这是因为他们都是通过调用Linux的内核调用来实现的。Linux的基本文件操作函数包括open,read,write,iseek,close

    打开文件函数:#include <sys/types.h>

            #include <sys/stat.h>

            #include <fcntl.h>

            int open(const char *pathname, int flags);//打开一个现有的文件    

            int open(const char *pathname, int flags, mode_t mode);

            //如果打开文件不存在,则先创建它

    关闭文件函数:#include <unistd.h>

            int close(int fd);

    创建文件函数:#include <sys/types.h>

            #include <sys/stat.h>

            #include <fcntl.h>

            int creat(const char *pathname, mode_t mode);

        上面==int open(const char *pathname, O_WRONLY|O_CREAT|O_TRUNC, mode_t mode);

    写文件函数:#include <unistd.h>

            ssize_t write(int fd, void *buf, size_t count);

    文件偏移定位函数:#include <sys/types.h>

            #include <unistd.h>

            off_t lseek(int fds, off_t offset, int whence);

    读文件函数:#include <unistd.h>

            ssize_t read(int fd, void *buf, size_t count);

Linux的高级文件操作:

    文件状态操作函数:#include <sys/type.h>

            #include <sys/stat.h>

            int stat(const char *pathname, struct stat *sbuf);

            int fstat(int fd, struct stat *sbuf);

            int lstat(const char *pathname,,struct stat *sbuf);

    时间相关函数:    unsigned longst_atime;    //最近一次访问文件时间

            unsigned longst_mtime;    //最近的修改文件时间

            unsigned longst_ctime;    //最近一次对文件状态进行修改的时间

            #include <sys/types.h>

            #include <utime.h>

            int utime(const char *pathname, const struct utimebuf *times);

10-10Linux的文件操作函数以及所需头文件的更多相关文章

  1. C语言文件操作函数

    C语言文件操作函数大全 clearerr(清除文件流的错误旗标) 相关函数 feof表头文件 #include<stdio.h> 定义函数 void clearerr(FILE * str ...

  2. Delphi文件操作函数

    文件是同一种类型元素的有序集合,是内存与外设之间传输数据的渠道.文件的本质是一个数据流,所有的文件实际上是一串二进制序列.文件管理包括:1.文件操作.2.目录操作.3.驱动器操作.三部分. 1.常见文 ...

  3. PHP文件操作系统----主要的文件操作函数

    一.文件操作系统概述 1.概述: php中的文件操作系统主要是对文件和目录的操作.文件在windows系统下分为3种不同:文件.目录.未知,在linux/unix系统下分为7种不同:block.cha ...

  4. unix文件操作函数

    1. fopen函数 #include <stdio.h> FILE *fopen(const char *path, const char *mode) 返回:文件顺利打开后,指向该流的 ...

  5. c语言文件操作函数详解

    一.文件操作注意点: 1 打开文件时,如果打开方式加“+”,表示该文件可以“写” ; 2 退出程序一般用exit函数,正常退出参数为0,非正常退出参数为正零值 ; 3 文件的读写操作:按字符.字符串. ...

  6. 【阅读笔记】《C程序员 从校园到职场》第六章 常用文件操作函数 (Part 1)

    参考链接:https://blog.csdn.net/zhouzhaoxiong1227/article/details/24926023 让你提前认识软件开发(18):C语言中常用的文件操作函数总结 ...

  7. Linux C 文件操作函数(~上善止水~)

    翻翻笔记,整理一下 C 语言中的文件操作函数 ~~~~~~,多注意细节,maybe 细节决定成败~ 1. fopen /* fopen(打开文件) * * 相关函数 open,fclose * * 表 ...

  8. 文件操作(FILE)与常用文件操作函数

    文件 1.文件基本概念 C程序把文件分为ASCII文件和二进制文件,ASCII文件又称文本文件,二进制文件和文本文件(也称ASCII码文件)二进制文件中,数值型数据是以二进制形式存储的, 而在文本文件 ...

  9. C语言文件操作函数大全(超详细)

    C语言文件操作函数大全(超详细) 作者: 字体:[增加 减小] 类型:转载 本篇文章是对C语言中的文件操作函数进行了详细的总结分析,需要的朋友参考下   fopen(打开文件)相关函数 open,fc ...

随机推荐

  1. python + docker, 实现天气数据 从FTP获取以及持久化(一)

    前情提要 最近项目需要天气数据(预报和历史数据)来作为算法程序的输入. 项目的甲方已经购买了天气数据, 依照他们的约定,天气数据的供应商会将数据以"文本" (.TXT)的方式发到F ...

  2. login oracle as sysdba

  3. 人脸检测及识别python实现系列(2)——识别出人脸

    人脸检测及识别python实现系列(2)——识别出人脸 http://www.cnblogs.com/neo-T/p/6430583.html

  4. partial function

    [partial function] functools.partial(func[,*args][, **keywords]) Return a new partial object which w ...

  5. SOAP 版本可能不匹配: 出现意外的 Envelope 命名空间 http://schemas.xmlsoap.org/wsdl/

    原错误描述:SOAP 版本可能不匹配: 出现意外的 Envelope 命名空间 http://schemas.xmlsoap.org/wsdl/.应为 http://schemas.xmlsoap.o ...

  6. Gcc And MakeFile Level1

    简单介绍gcc And make 的使用 基本编译 gcc a.c b.c -o exeName 分步编译 gcc -c a.c -o a.o gcc a.o b.c -o main.o 使用Make ...

  7. code3286 火柴排队

    这道题目相当于是让我们把a,b对齐,即a中第i大的数与b中第i大的数下标相同一看到交换次数,很容易让人想到归并排序我的做法是这样的就样例而言:a:1 3 4 2b:1 7 2 4读进来之后先处理a,b ...

  8. dedecms图片上传函数

    /** * 图片上传类 * @param $file上传图片信息 * @param $ty */ function upload_pic($file, $ty) { if (!is_uploaded_ ...

  9. file_get_contents()

    file_get_contents()类似于curl接口调用

  10. centos6.5修改root密码

    转:https://blog.csdn.net/cui1834515/article/details/77860113