C'est une petite fonction en C qui copie un répertoire en récursif sous Windows.
Elle marche quand il n'y a pas trop grand chose à parcourir, en revanche si on prend un dossier trop grand, plantage de la cmd :s

voici le code :
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
 
/** copie de Dossier (cp -r) */
void mycpR(char *FullPathSource, char *FullPathDest){
#ifdef WIN32
    WIN32_FIND_DATA file;
    HANDLE find;
    char *pathname;
    char *tmpSrc;
    char *tmpDest;
    int taille;   
    LPSECURITY_ATTRIBUTES attr=NULL;
 
    // Si le dossier source existe
    if (existFile(FullPathSource)==0) {
	// Si le dossier de Dest n'existe pas
	if (existFile(FullPathDest)==-1){
	    // Alors on le crée ;)
	    if (!CreateDirectory(FullPathDest,attr)){
		printf("/!\\ Error creation du dossier %s/!\\\n",FullPathDest);
	    }
	}
	// On ajoute le \*.* pour le FindFirstFile
	pathname = (char *)malloc(strlen(FullPathSource) + 4);
	strcpy(pathname, FullPathSource);
	strcat(pathname, "\\*.*");
	printf("/!\\ Exploration du dossier : %s /!\\\n",pathname);
 
	find = FindFirstFile(pathname, &file);
	if (find != INVALID_HANDLE_VALUE){    
    	    do{
		// Fichier courant (path global)
		taille=strlen(file.cFileName) + strlen(FullPathSource)+2;
		tmpSrc = (char *) malloc(taille);
		strcpy(tmpSrc, FullPathSource);
		strcat(tmpSrc,"\\");
		strcat(tmpSrc, file.cFileName);
		tmpSrc[taille-1]='\0';
//		printf("Folder : %s\n",tmpSrc);
 
 
		// Fichier Dest (path global)
		taille=strlen(file.cFileName) + strlen(FullPathDest)+2;
		tmpDest = (char *) malloc(taille);
		strcpy(tmpDest, FullPathDest);
		strcat(tmpDest,"\\");
		strcat(tmpDest, file.cFileName);		
		tmpDest[taille-1]='\0';
 
		// Si c'est un dossier
		if (file.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY){
		    // qui commence pas par un . (pour éviter . et ..)
    		    if (file.cFileName[0] != '.'){
			// récursivité ^^	
    			mycpR(tmpSrc,tmpDest);
    		    }		
    		}
		// sinon (cé un fichier)
    		else{
		    // on le copie :p
    		    printf("\t#cp %s %s\n",tmpSrc,tmpDest);
//		    mycp(tmpSrc,tmpDest);
    		}
 
		// libération mémoire
		free(tmpSrc);
		free(tmpDest);    
    	    }while(FindNextFile(find, &file));        	    
	}
 
	// libération mémoire
	FindClose(find);
	free(pathname);
    }
#endif    
}
 
 
 
 
 
/** Test d'existance d'un fichier */
int existFile(char *fichier){
 
    if ( access(fichier, F_OK)==-1 ){
        printf("Error Access File : %s :\\\n",fichier);
        return -1;
    }
    else
        return 0;
}
Merci pour l'aide