This repository was archived by the owner on Mar 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathafficher_attribut.c
More file actions
55 lines (46 loc) · 1.6 KB
/
afficher_attribut.c
File metadata and controls
55 lines (46 loc) · 1.6 KB
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
#include<stdio.h>
#include<unistd.h>
#include<dirent.h>
#include<sys/types.h>
#include<stdlib.h>
#include<sys/stat.h>
void afficher_contenu(struct stat *info)
{
if(S_ISBLK(info->st_mode))
fprintf(stdout," fichier: block, <permission> : ");
else if (S_ISCHR(info->st_mode))
fprintf(stdout," fichier: caractere, <permission> : ");
else if (S_ISDIR(info->st_mode))
fprintf(stdout," fichier: repertoire, <permission> : ");
else if (S_ISREG(info->st_mode))
fprintf(stdout," fichier: regulier, <permission> : ");
else if (S_ISLNK(info->st_mode))
fprintf(stdout," fichier: lien, <permission> : ");
else if (S_ISFIFO(info->st_mode))
fprintf(stdout,"fichier: fifo, <permission> : ");
else if(S_ISSOCK(info->st_mode))
fprintf(stdout,"fichier: socket, <permission> : ");
fprintf(stdout, " [utilisateur] :");
fprintf(stdout, info->st_mode & S_IRUSR ? "r" :"-");
fprintf(stdout, info->st_mode & S_IWUSR ? "w" :"-");
fprintf(stdout, info->st_mode & S_IXUSR ? "x" :"-");
fprintf(stdout, " [groupe] :");
fprintf(stdout, info->st_mode & S_IRGRP ? "r" :"-");
fprintf(stdout, info->st_mode & S_IWGRP ? "w" :"-");
fprintf(stdout, info->st_mode & S_IXGRP ? "x" :"-");
fprintf(stdout, " [other] :");
fprintf(stdout, info->st_mode & S_IROTH ? "r" :"-");
fprintf(stdout, info->st_mode & S_IWOTH ? "w" :"-");
fprintf(stdout, info->st_mode & S_IXOTH ? "x" :"-");
fprintf(stdout, "\n");
}
int main(void)
{
struct stat etat_fichier;
char fichier[512];//un fichier absolue
printf("entrer le nom absolu du fichier :\n");
scanf("%s",fichier);
stat(fichier,&etat_fichier);
afficher_contenu( &etat_fichier);
return 0;
}