#include #include #include #include #include #include int showDir(const char * path,int level) { int i; struct stat infos; struct dirent * entry; DIR * dir=opendir(path); if(!dir) return(-1); do { entry=readdir(dir); if(entry) { char buffer[0x100]; buffer[0]='\0'; strcat(buffer,path); strcat(buffer,"/"); strcat(buffer,entry->d_name); if(stat(buffer,&infos)!=-1) { if(S_ISDIR(infos.st_mode)) { if(strcmp(entry->d_name,".")&&strcmp(entry->d_name,"..")) { for(i=0;id_name); showDir(buffer,level+1); } } else if(S_ISREG(infos.st_mode)) { for(i=0;id_name); } } } } while(entry); closedir(dir); return(0); } int main(int argc,char ** argv) { const char * path=(argc>1 ? argv[1] : "."); showDir(path,0); return(0); }