![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
【C/C++文件处理系列】
natpan
keep learning
展开
-
【C/C++文件处理系列】fstream::open函数打开文件
【fstream::open】函数原型void open (const char* filename, ios_base::openmode mode = ios_base::in | ios_base::out);其中 filename 为文件名字openmode 如下:in input 以读的方式打开,即input 内存...原创 2018-08-03 22:49:01 · 26240 阅读 · 0 评论 -
【C/C++文件处理系列】struct stat 结构体定义
获取文件状态的函数 stat fstat lstat 都与struct stat 有关。函数原型如下,都定义在 sys/stat.h 中,原型如下 int stat(const char *path, struct stat *buf); int fstat(int fd, struct stat *buf); int lstat(const char *path, struct...原创 2018-08-06 14:27:55 · 1417 阅读 · 0 评论 -
【C/C++文件处理系列】通过stat()函数获取struct stat结构的信息
【stat】函数原型:stat() stats the file pointed to by path and fills in buf获取指定路径的文件信息并保存到struct stat类型的结构体中int stat(const char *path, struct stat *buf);struct stat 结构体 详见struct stat定义链接代码实现#...原创 2018-08-08 14:32:57 · 2981 阅读 · 0 评论 -
【C/C++文件处理系列】通过struct stat中的st_mode判断文件类型
linux系统文件类型有七种,即:普通文件、目录文件、字符设备、块设备、管道文件、链接文件和套接字文件。通过 man 2 stat 可获取到 其中 st_mode 可以用来判别服务的类型。原文如下:The following POSIX macros are defined to check the file type using the st_mode field: ...原创 2018-08-13 13:58:50 · 2821 阅读 · 0 评论