2018年1月15日

fcntl函数用法——设置文件锁

摘要: fcntl函数。锁定文件,设置文件锁。设置获取文件锁:F_GETLK 、F_SETLK 、F_SETLKW文件锁结构,设置好用于fcntl函数的第三个参数。struct flock{ short l_type;//锁的类型 F_RDLCK,F_WRLCK(排他锁),F_UNLCK(清除锁) shor 阅读全文

posted @ 2018-01-15 20:32 wsw_seu 阅读(1353) 评论(0) 推荐(0) 编辑

fcntl函数用法——操纵文件描述符状态

摘要: fcntl函数:操纵文件描述符,改变已经打开的文件的属性int fcntl(int fd, int cmd, ... //arg );cmd选项:一、复制文件描述符:F_DUPFD二、更改设置文件描述标志:F_GETFD 、F_SETFD 文件描述符标志,是体现进程的文件描述符的状态.当前只定义了一 阅读全文

posted @ 2018-01-15 20:15 wsw_seu 阅读(570) 评论(0) 推荐(0) 编辑

fcntl函数用法——复制文件描述符

摘要: 文件描述符复制和输出重定向dup() 用最小的文件描述符来复制,从0开始搜素。复制文件描述符后,最小文件描述符指向被复制描述符指向的文件。dup2(int oldfd,int newfd) 强制用newfd来复制oldfd close(1);dup(fd) == 》等价于dup2(fd,1)int 阅读全文

posted @ 2018-01-15 19:41 wsw_seu 阅读(436) 评论(0) 推荐(0) 编辑

文件共享

摘要: 文件描述符指向文件表,一个进程默认打开1024个文件描述符。 文件表中保存了:文件状态标志(可读、可写、追加、同步、非阻塞等)、文件偏移量、refcnt(引用计数)、v结点指针(指向v结点表--v结点信息stat函数可以查看、i结点信息) 文件在磁盘块的位置: i结点信息. 若一个进程两次打开同一个 阅读全文

posted @ 2018-01-15 19:22 wsw_seu 阅读(117) 评论(0) 推荐(0) 编辑

stat函数

摘要: 一、stat 函数,获取文件元数据 int stat(const char *path, struct stat *buf); int fstat(int fd, struct stat *buf); int lstat(const char *path, struct stat *buf); 二、 阅读全文

posted @ 2018-01-15 18:38 wsw_seu 阅读(5132) 评论(0) 推荐(0) 编辑

字符串类的实现

摘要: #pragma once #include using namespace std; class String { public: String(const char* str = ""); String(const String& other); String& operator=(const String& other); String& operator=(... 阅读全文

posted @ 2018-01-15 09:35 wsw_seu 阅读(896) 评论(0) 推荐(0) 编辑

导航