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. 第5课 Qt Creator工程介绍

    1. QT Creator工程管理(一个工程包含不同类型的文件) (1).pro项目文件 (2).pro.user用户配置描述文件 (3).h头文件 (4).cpp源文件 (5).ui界面描述文件 ( ...

  2. PyQt5系列教程(一)Mac OS X下搭建Python3.5.1+PyQt5开发环境

    软硬件环境 OS X EI Capitan Python 3.5.1 PyQt 5.5.1 PyCharm 5.0.1 前言 Qt是一个开源的跨平台的GUI框架,为很多计算机语言提供了应用程序开发接口 ...

  3. delphi 路径函数

    delphi path functionIncludeTrailingPathDelimiterIncludeTrailingPathDelimiter ensures that a path nam ...

  4. partial function

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

  5. blocking network call

    [blocking network call] 阻塞的网络调用: 1.gethostbyname(): does not return until it has succeeded or failed ...

  6. sqlserver查询存储过程的创建时间及最后修改时间

    select  [name] ,create_date ,modify_date FROM  sys.all_objects where  type_desc = N'SQL_STORED_PROCE ...

  7. Linux下patch的制作和应用

    转自:http://blog.chinaunix.net/u3/100239/showart_1984963.html 首先介绍一下diff和patch.在这里不会把man在线文档上所有的选项都介绍一 ...

  8. C语言源字符集与执行字符集

    参考: http://blog.csdn.net/yucan1001/article/details/7188267   http://blog.csdn.net/dbzhang800/article ...

  9. Spring MVC的handlermapping之请求分发如何找到正确的Handler(BeanNameUrlHandlerMapping,SimpleUrlHandlerMapping)

    本文讲的是Spring MVC如何找到正确的handler, 前面请求具体怎么进入到下面的方法,不再细说. 大概就是Spring mvc通过servlet拦截请求,实现doService方法,然后进入 ...

  10. IRC聊天指南

    参考https://www.cnblogs.com/fzzl/archive/2011/12/26/2302637.html