在windows下可以通过
_findfirst()
和_findnext()
实现对文件的遍历和操作
// intptr_t 32位下位int 64位下位long long
intptr_t _findfirst( const char *fileName, struct _finddata_t *fileData );
// 调用成功返回一个唯一编号(句柄),失败返回-1
// fileName 文件名称 支持通配符
// _fileData 文件信息 后面会解释这个结构体
int _findnext( long _findHandle, struct _finddata_t *fileData );
// _findHandle _findfirst得到的句柄
// findData 文件信息
int _findclose( long handle );
_finddata_t
在win下区分32位和64位 实质内容一致
struct __finddata64_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;
__int64 size;
char name[260];
};
struct _finddata32_t
{
unsigned attrib; // 文件属性 后面会解释
__time32_t time_create; // 文件创建时间
__time32_t time_access; // 文件最后一次访问时间
__time32_t time_write; // 文件最后一次被写时间
_fsize_t size; // 文件大小
char name[260]; // 文件名称
};
// File attribute constants for the _findfirst() family of functions
#define _A_NORMAL 0x00 // Normal file - No read/write restrictions 正常
#define _A_RDONLY 0x01 // Read only file 只读
#define _A_HIDDEN 0x02 // Hidden file 隐藏
#define _A_SYSTEM 0x04 // System file 系统
#define _A_SUBDIR 0x10 // Subdirectory 子文件夹
#define _A_ARCH 0x20 // Archive file 存档