欢迎使用CSDN-markdown编辑器
2015-07-16 09:45
357 查看
Unix系统API汇集
fileno: 将文件指针转换成文件描述符 int fileno(FILE *stream); fdopen: 将文件描述符转换成文件指针 FILE *fdopen(int fd, const char *mode);
#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); ssize_t read(int fd, void *buf, size_t count); 返回值: 错误: -1 到达文件尾: 0 成功: 返回从文件复制到规定缓冲区的字节数 ssize_t write(int fd, const void *buf, size_t count); 返回值: 错误: -1 什么都没做: 0 int fsync(int fd); off_t lseek(int fd, off_t offset, int whence); 返回值: 新的文件偏移值; Whence取值: SEEK_SET The offset is set to offset bytes. SEEK_CUR The offset is set to its current location plus offset bytes. SEEK_END The offset is set to the size of the file plus offset bytes.
#include <sys/types.h> #include <dirent.h> DIR *opendir(const char *name); 返回值: 成功: 返回目录指针; 失败: 返回NULL; struct dirent *readdir(DIR *dirp); 返回值: 成功: 返回一个指向dirent结构的指针, 它包含指定目录的下一个连接的细节; 没有更多连接时, 返回0; struct dirent { ino_t d_ino; /* inode number */ off_t d_off; /* not an offset; see NOTES */ unsigned short d_reclen; /* length of this record */ unsigned char d_type; /* type of file; not supported by all filesystem types */ char d_name[256]; /* filename */ }; int closedir(DIR *dirp); int mkdir(const char *pathname, mode_t mode); int rmdir(const char *pathname); Chmod, fchmod更改权限 int chmod(const char *path, mode_t mode); int fchmod(int fd, mode_t mode); chown,fchown更改文件所有者/所属组 int chown(const char *path, uid_t owner, gid_t group); int fchown(int fd, uid_t owner, gid_t group);
相关文章推荐
- PHP实现通过get方式识别用户发送邮件的方法
- grafana-zabbix安装简明教程
- eclipse跳转当前文件的目录下
- 分布式中的事务?
- grafana-zabbix安装简明教程
- 获取某一文件夹下特别创建时间以后的文件
- Android 自定义圆形图片和文本
- 黑马day18 JQuery自定义插件
- Redis简介
- 下载第三方类库编译报错
- iOS学习笔记-ViewController/生命周期
- Swift iOS开发中出现“no such module cocoa”的错误
- js里父页面与子页面的相互调用
- apache+svn服务搭建
- POJ 2114 Boatherds 点分治
- Android ant自动打包APK
- Android ListView滑动过程中图片显示重复错位闪烁问题解决
- 简单实现Redis缓存中的排序功能(三)
- jQuery之常用且重要方法
- O2O的攻坚战役:美团如何应对百度腾讯夹击?