Bonjour, je regarde tous les fils d'un dossier avec cette fonction :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
int ListeRep::analyseDir(string pdir, string& nom)
{
	string srcfile;
	struct dirent *mydir;
	static DIR *rep;
	static int n=0;
	int res=ListeRep::FIN;
	int i;
 
	if (pdir!="")
		n=0;
 
	if ( pdir[pdir.size()-1]=='/' )
		pdir.resize(pdir.size()-1);
 
	rep=opendir(pdir.c_str());
	if (rep!=NULL)
	{
		i=0;
		while( (mydir=readdir(rep)) )
		{
			if (i==n)
			{
				string fichier(mydir->d_name);
				if ( isFile(fichier) )
				{
					srcfile=pdir + '/' + fichier;
					nom=srcfile;
					string taille(utile::all2string(tailleFichier(srcfile)));
 
					#ifdef __linux__
					struct stat st;
					int status;
					status=lstat(srcfile.c_str(),&st);
					if ( !S_ISLNK(st.st_mode))
					{
					#endif
 
					if( !isdir(srcfile) )
					{
 
						if (fichierTmp(fichier) && formatOK(fichier))
							res=ListeRep::FICHIER;
					}
					else
						res=ListeRep::DOSSIER;
 
					#ifdef __linux__
					}
					#endif
				}
 
				res=ListeRep::CONTINUE;
 
				n++;
				closedir(rep);	
 
				srcfile.erase();
				fichier.erase();
 
				return res;
			}
			i++;
		}
 
		closedir(rep);
	}
 
	return res;
 
}
Je voudrais qu'elle me renvoie le type du fils pour chaque fils et faire :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
	string nom("");
	int res=ListeRep::analyseDir(this->courant,nom);
	while(res!=ListeRep::FIN)
	{
		cout << nom << endl << res << endl;
		res=ListeRep::analyseDir("",nom);
	}
pour avoir tous les fils.

NB : FIN, DOSSIER, CONTINUE, FICHIER sont dans un enum.