系统IO

系统IO:Linux系统提供给应用程序操作文件的接口

Everything is a file  ,in  Unix

在Unix/Linux下,万物皆文件

打开文件函数原型:

#include<sys/types.h>

#include<sys/stat.h>

#include<fcntl.h>

int open(const char *path, int flag);

int open(const char *path, int flag, mode_t mode);

读函数原型:

#include<unistd.h>

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

写函数原型:

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

定位文件函数:

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

关闭函数:

int close(int fd);

文件映射函数:

#include<sys/mman.h>

void* mmap(void* addr, size_t length, int prot, int flag, int fd, off_t offset );

关闭文件映射函数:

int munmap(void* add, size_t length);

原文地址:https://www.cnblogs.com/huang-y-x/p/10296954.html