以下是我用来获取当前文件夹中所有文件夹列表的代码片段。我想得到红色的“。” 和“..”列表中的文件夹,但不知何故不能。
const char* root_dir_c = root_dir.c_str();
DIR *pdir = opendir(root_dir_c);
struct dirent *entry = readdir(pdir);
while (entry != NULL){
if ((entry->d_type == DT_DIR) && (entry->d_name != ".") && (entry->d_name != "..")){
// DO STUFF
}
entry = readdir(pdir);
}
你能帮忙吗?