void show_dir(char *dname)
{
DIR *dp;
struct dirent *dentp;
char buffer[SIZE];
printf("%s:\n",dname);
dp = opendir(dname);
while((dentp = readdir(dp)) != NULL)
{
snprintf(buffer,SIZE,"%s/%s",dname,dentp->d_name);
show_file(buffer);
}
printf("\n");
rewinddir(dp);
while((dentp = readdir(dp)) != NULL)
{
if(!strcmp(dentp->d_name,".") || !strcmp(dentp->d_name,".."))
{ continue; }
snprintf(buffer,SIZE,"%s/%s",dname,dentp->dname);
if(is_dir(buffer)) { show_dir(buffer); }
}
}
阅读(552) | 评论(0) | 转发(0) |