现在整理一下读文件和写文件。
这一版面:
1.遍历所有文件
2.字符串大小写转换
3.筛选指定后缀的文件
4.替换文件指定字符串
C++中读取文件可以采用几个函数分别为,_findfirst、_findnext、_findclose。其中还要借助结构体 struct _finddata_t,_finddata_t主要用来存储各种文件的信息。
struct _finddata64i32_t {
unsigned attrib;
__time64_t time_create; /* -1 for FAT file systems */
__time64_t time_access; /* -1 for FAT file systems */
__time64_t time_write;
_fsize_t size;
char name[260];
};
其中 unsigned attribute 表示文件的属性,分别有以下几种。
_A_ARCH(存档)
_A_HIDDEN(隐藏)
_A_NORMAL(正常)
_A_RDONLY(只读)
_A_SUBDIR(文件夹)