读取文件
使用 sys/stat.h
struct stat st;
stat(path.c_str, &st);
-
判定是否文件夹
S_ISDIR(st.st_mode) -
判定是否文件
S_ISREG(st.st_mode)
使用 dirent.h
DIR *pdir;
pdir = opendir(path);
struct dirent *pdirent;
pdirent = readdir(pdir);
string filename = pdirent->d_name;
-
判定是否文件夹
pdirent->d_type & DT_DIR -
判定是否文件
pdirent->d_type & DT_REG