Bonjour, je suis actuellement en train de recoder la fonction ls (un projet de mon ecole)
je bloque a cause de la fonction stat.
apparament, il y a une erreur dans mon code car avec
mon programme m'affiche tout fièrement
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 void aff_right(struct stat *recupstat) { if ((S_IFMT & recupstat->st_mode) == S_IFREG) printf("-"); else if ((S_IFMT & recupstat->st_mode) == S_IFDIR) printf("d"); else if ((S_IFMT & recupstat->st_mode) == S_IFCHR) printf("c"); else if ((S_IFMT & recupstat->st_mode) == S_IFBLK) printf("b"); else if ((S_IFMT & recupstat->st_mode) == S_IFIFO) printf("p"); else if ((S_IFMT & recupstat->st_mode) == S_IFLNK) printf("l"); else if ((S_IFMT & recupstat->st_mode) == S_IFSOCK) printf("s"); else printf("?"); ((recupstat->st_mode & S_IRUSR) == S_IRUSR) ? printf("r") : printf("-"); ((recupstat->st_mode & S_IWUSR) == S_IWUSR) ? printf("w") : printf("-"); ((recupstat->st_mode & S_IXUSR) == S_IXUSR) ? printf("x") : printf("-"); ((recupstat->st_mode & S_IRGRP) == S_IRGRP) ? printf("r") : printf("-"); ((recupstat->st_mode & S_IWGRP) == S_IWGRP) ? printf("w") : printf("-"); ((recupstat->st_mode & S_IXGRP) == S_IXGRP) ? printf("x") : printf("-"); ((recupstat->st_mode & S_IROTH) == S_IROTH) ? printf("r") : printf("-"); ((recupstat->st_mode & S_IWOTH) == S_IWOTH) ? printf("w") : printf("-"); ((recupstat->st_mode & S_IXOTH) == S_IXOTH) ? printf("x\n") : printf("-\n"); }
?-wx-----x
?-wx-----x
?-wx-----x
?-wx-----x
?-wx-----x
au lieu de :
-rwxr-xr-x
-rw-r--r--
-rw-r--r--
-rw-r--r--
-rw-r--r--
alors voila, j'ai chercher sur internet pas mal de temps, mais impossible de changer quoi que ce soit...
Partager