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. 使用GridFsTemplate在mongodb中存取文件

    spring-data-mongodb之gridfs   mongodb除了能够存储大量的数据外,还内置了一个非常好用的文件系统.基于mongodb集群的优势,GridFS当然也是分布式的,而且备份也 ...

  2. uedit富文本编辑器及图片上传控件

    微力后台 uedit富文本编辑器及文件上传控件的使用,无时间整理,暂略,参考本地代码.能跑起来.

  3. C#中StreamWriter与BinaryWriter的区别兼谈编码。

    原文:http://www.cnblogs.com/ybwang/archive/2010/06/12/1757409.html 参考: 1. <C#高级编程>第六版 2.  文件流和数据 ...

  4. Visual Basic 函数速查

    Calendar 常数 可在代码中的任何地方用下列常数代替实际值: 常数 值 描述 vbCalGreg 0 指出使用的是阳历. vbCalHijri 1 指出使用的是伊斯兰历法. Color 常数 可 ...

  5. Spark报错:Failed to locate the winutils binary in the hadoop binary path

    之前在mac上调试hadoop程序(mac之前配置过hadoop环境)一直都是正常的.因为工作需要,需要在windows上先调试该程序,然后再转到linux下.程序运行的过程中,报 Failed to ...

  6. k8s问题记录

    1. kubectl run 起来的pod 用 kubectl delete po删不掉 kubectl delete deployment my-nginx kubelet# 看到最后一行:erro ...

  7. $in 操作符

    [$in 操作符] The $in operator selects the documents where the value of a field equals any value in the ...

  8. Redis 发布/定阅

    [Redis 发布/定阅] 1.SUBSCRIBE channel [channel ...] 订阅给定的一个或多个频道的信息. 2.PSUBSCRIBE pattern [pattern ...] ...

  9. 模m的剩余类里的一切数与m的最大公约数相等

    [模m的剩余类里的一切数与m的最大公约数相等] 设剩余类里的任意两元素,a.b.则: a=mq1+r1, b= mq2+r1. 根据上式可得,(a,m)=(m,r1), (b,m)=(m,r2).可推 ...

  10. 生产者消费者模式做一个golang的定时器

    在主程序启动的时候开一个goroutine作为消费者,用管道连接生产者和消费者,消费者处于无限循环,从管道中获取channel传过来定时event 注意:channel在消费者创建的时候就连通生产者和 ...