Bonjour a tous!!!,
J'ai creer un programme qui a pour but de simuler la commande FIND avec des paramètre.
mais lorsque je tente d'executer mon programme il me retourne une erreur de ";" attendu mais je n'arrive pas a corrige ce probleme je vous joint le code ci dessous:

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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
 
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <sys/types.h>
#include <time.h>
#include <errno.h>
#include <sys/stat.h>
 
void help (void)
{
    // le manuel
}
void tree (char *filename, int marque,int printout)
{
            DIR* rep=NULL; //pointeur dir
            struct dirent *fichierLU; //instanciation provenant de la biblioteque dirent.h pointeur
            rep = opendir("."); //ouverture d'un dossier actuel, rÈcent
            char memrep[500]; //tempon du repertoire
            fichierLU = readdir(rep); //prend le repertoire rep
            struct stat dir_stat;
            getcwd(memrep, 500);
            struct _stat buf;
            int result;
            char *timebuf;
            int timer;
 
        while ((fichierLU=readdir(rep))!=NULL){ //boucle
            if(strcmp(fichierLU->d_name,"..")!=0 &&(fichierLU->d_name && strstr(fichierLU->d_name, filename)))
{
                if(printout==1)
                {
                    printf("%s/%s\n", memrep,fichierLU->d_name);
 
                        if (marque==1)
                        {
                            result = stat (fichierLU->d_name, &buf);
                            timebuf = ctime(&buf.st_ctime);
                            printf ("Date de creation: %s", timebuf);
                        }
 
                        if (marque==2)
                        {
                            result = stat (fichierLU->d_name, &buf);
                            timebuf = ctime(&buf.st_mtime);
                            printf ("Date de modification: %s", timebuf);
                        }
 
                        if (marque==3)
                        {
                            result = stat (fichierLU->d_name, &buf);
                            timebuf = ctime(&buf.st_atime);
                            printf ("Derniere ouverture du fichier: %s", timebuf);
                        }
 
                    if(stat(fichierLU->d_name, &dir_stat)==-1)
                    perror("stat");
 
                    if(strcmp(".",fichierLU->d_name)  == 0 ||strcmp("..",fichierLU->d_name) == 0)
                        continue;
                ;
                    if (S_ISDIR(dir_stat.st_mode)) {
                    //change into the new directory
                        if (chdir(fichierLU->d_name) == -1)
                        {
 
                        perror("");
                        continue;
                        }
 
                        tree(filename,marque,printout);
                        chdir("..");
                    }
 
        }
}
int main(int argc, char* argv [])
{
    char* dir_path; //path to the directory
    char* filename; // pattern to match
    char *pw_name;
    struct stat dir_stat; //used by stat
    int i;
    int marqueur=0;
    int printout=0;
 
    if (argc<2)
    {
        printf("arguments insufisants");
        return 1;
    }
for (i=1;argv[i];i++)
{
    if ((((argv[i][0]=='C')&& (argv[i][1]==':')||(argv[i][0]=='C')&&(argv[i][1]==':')||(argv[i][0]=='/')))) // partie de gauche C: Windows / partie de droite / pour linux
} ;
 
//printf("%s",dir_path);
 
    for (i=1, argv[i], i++)
{
    if(strcmp(argv[i],"-ctime")==0)
    {
        marqueur=1;
    }
 
    if (strcmp(argv[i],"-atime")==0)
    {
        marqueur=2;
    }
 
    if (strcmp(argv[i],"mtime")==0)
    {
        marqueur=3;
    }
}
    for(i=0;argv[i];i++)
    {
        if ((strcmp(argv[i]),"-help"==0 ||(strcmp(argv[i]),"--help")==0)
    }
for (i=1;argv[o;i++])
{
 
 
    if(strcmp(argv[i],"-name")==0)  //argument -name making the find searching by name
    {
            printout=1;
            filename=argv[i+1];
        if (stat(dir_path, &dir_stat)== -1) {
perror("stat");
exit(1);
    }
        if (!S_ISDIR(dir_stat.st_mode)) {
fprintf(stderr, "'%s' is not a directory\n", dir_path);
exit(1);
    }
 
    // change into the given directory
    if (chdir(dir_path) == -1) {
fprintf(stderr, "Cannot change to directory '%s': ", dir_path);
perror("");
exit(1);
 
    }
}
    //else return 0;
}
 
 
        tree(filename,marqueur,printout);
 
 
    // }
    return 0;
}
Merci d'avance pour votre aide