1 #include<sys/types.h>
 2 #include <stdio.h> 
 3 #include <dirent.h>
 4 
 5 #define EMPTY                1005
 6 #define NON_EMPTY        1006
 7 
 8 int check_dir(const char *path)
 9 {
10     DIR *pDir = NULL;
11     struct dirent *p_dirent;
12     pDir = opendir(path);
13     if(pDir==NULL){
14         printf("open %s fail\n",path);
15         return -1;
16     }
17     while(p_dirent=readdir(pDir)){
18         if(strcmp(p_dirent->d_name,".")!=0&&strcmp(p_dirent->d_name,"..")!=0)//空目录也有"."和".."文件
19             return NON_EMPTY;
20     }
21     return EMPTY;
22 
23 }

 

posted on 2014-06-10 16:22  江左醉风流  阅读(3149)  评论(0编辑  收藏  举报