-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparcours.c
executable file
·31 lines (27 loc) · 936 Bytes
/
parcours.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "head.h"
void parcourir_repertoire(const char* chemin,int type, int suivre_lien){
DIR *dir = opendir(chemin);
struct dirent *entry;
struct stat dir_stat;
if (! dir)
{
perror(chemin);
return;
}
//treat(chemin, exp);
while((entry = readdir(dir)) != NULL){//traiter_fichier(buff, exp, suivre_lien);
char buff[strlen(chemin)+strlen(entry->d_name)+2];
sprintf(buff,"%s/%s",chemin,entry->d_name);
suivre_lien ? stat(buff, &dir_stat) : lstat(buff,&dir_stat);//pourquoii???????
//printf("%s\t%s\n",chemin,path);
if(strcmp(entry->d_name,"..") != 0){
if(((dir_stat.st_mode & S_IFMT) == S_IFDIR) && strcmp(entry->d_name, ".") != 0){
treat(buff, type);
parcourir_repertoire(buff, type, suivre_lien);
}
else
treat(buff, type);
}
}
closedir(dir);
}