Revoked inflation of file type characters to words

This commit is contained in:
Thomas Schmitt 2008-02-20 23:29:46 +00:00
parent 2c1f9280a0
commit c30b023a6b

View File

@ -25,8 +25,11 @@
#include <time.h> #include <time.h>
/* @param flag bit0= single letters */
char *Ftypetxt(mode_t st_mode, int flag) char *Ftypetxt(mode_t st_mode, int flag)
{ {
if(flag&1)
goto single_letters;
if(S_ISDIR(st_mode)) if(S_ISDIR(st_mode))
return("directory"); return("directory");
else if(S_ISREG(st_mode)) else if(S_ISREG(st_mode))
@ -42,6 +45,22 @@ char *Ftypetxt(mode_t st_mode, int flag)
else if(S_ISSOCK(st_mode)) else if(S_ISSOCK(st_mode))
return("unix_socket"); return("unix_socket");
return("unknown"); return("unknown");
single_letters:;
if(S_ISDIR(st_mode))
return("d");
else if(S_ISREG(st_mode))
return("-");
else if(S_ISLNK(st_mode))
return("l");
else if(S_ISBLK(st_mode))
return("b");
else if(S_ISCHR(st_mode))
return("c");
else if(S_ISFIFO(st_mode))
return("p");
else if(S_ISSOCK(st_mode))
return("s");
return("?");
} }
@ -82,7 +101,7 @@ int Compare_2_files(char *adr1, char *adr2, char *adrc, int flag)
printf("? %s : cannot lstat() : %s\n", adr1, strerror(errno)); printf("? %s : cannot lstat() : %s\n", adr1, strerror(errno));
return(0); return(0);
} }
strcpy(a, Ftypetxt(s1.st_mode, 0)); strcpy(a, Ftypetxt(s1.st_mode, 1));
strcat(a, " "); strcat(a, " ");
if(adrc[0]) if(adrc[0])
strcat(a, adrc); strcat(a, adrc);