|  | @@ -10,10 +10,11 @@
 | 
	
		
			
				|  |  |  #include "color.h"
 | 
	
		
			
				|  |  |  #include "constante.h"
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -int printDir(struct dirent** contentsDir, char* path, int nbFile, struct stat info,
 | 
	
		
			
				|  |  | +int printDir(struct dirent** contentsDir, char* path, int nbFile,
 | 
	
		
			
				|  |  |                      boolean hiddenFile){
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    //char permission[10] = "----------";
 | 
	
		
			
				|  |  | +    struct stat info;
 | 
	
		
			
				|  |  | +    char permission[10] = "---------";
 | 
	
		
			
				|  |  |      int j = 0;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      //enleve les fichiers caches
 | 
	
	
		
			
				|  | @@ -21,6 +22,7 @@ int printDir(struct dirent** contentsDir, char* path, int nbFile, struct stat in
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      //Affiche les fichiers
 | 
	
		
			
				|  |  |      while(j < nbFile){
 | 
	
		
			
				|  |  | +        stat(contentsDir[j]->d_name, &info);
 | 
	
		
			
				|  |  |          /*switch(info.st_mode){
 | 
	
		
			
				|  |  |              case S_IRUSR:
 | 
	
		
			
				|  |  |                  permission[1] = 'r';
 | 
	
	
		
			
				|  | @@ -41,8 +43,7 @@ int printDir(struct dirent** contentsDir, char* path, int nbFile, struct stat in
 | 
	
		
			
				|  |  |              case S_IXOTH:
 | 
	
		
			
				|  |  |                  permission[9] = 'x';
 | 
	
		
			
				|  |  |          }*/
 | 
	
		
			
				|  |  | -        printf("%d  %ld  %s\n", info.st_mode, info.st_size, contentsDir[j]->d_name);
 | 
	
		
			
				|  |  | -        //printf("%s", permission);
 | 
	
		
			
				|  |  | +        printf("%s  %d  %ld  %s\n", permission, info.st_mode, info.st_size, contentsDir[j]->d_name);
 | 
	
		
			
				|  |  |          j++;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      printf("\n");
 | 
	
	
		
			
				|  | @@ -81,11 +82,7 @@ void ls(int argc, char* argv[]){
 | 
	
		
			
				|  |  |      //Time to display
 | 
	
		
			
				|  |  |      for(i = 1; i < argc; i++){
 | 
	
		
			
				|  |  |          if(argv[i][0] != '-'){
 | 
	
		
			
				|  |  | -            strcpy(path, buffer);
 | 
	
		
			
				|  |  | -            strcat(path, "/");
 | 
	
		
			
				|  |  | -            strcat(path, argv[i]);
 | 
	
		
			
				|  |  | -            if(stat(path, &info) == ERR)
 | 
	
		
			
				|  |  | -                addperror("Erreur stat");
 | 
	
		
			
				|  |  | +            stat(argv[i], &info);
 | 
	
		
			
				|  |  |              if(S_ISDIR(info.st_mode)){
 | 
	
		
			
				|  |  |                  nbFile = scandir(argv[i], &contentsDir, 0, alphasort);
 | 
	
		
			
				|  |  |                  if (nbFile < 0) {
 | 
	
	
		
			
				|  | @@ -96,7 +93,7 @@ void ls(int argc, char* argv[]){
 | 
	
		
			
				|  |  |                  strcpy(path, buffer);
 | 
	
		
			
				|  |  |                  strcat(path, "/");
 | 
	
		
			
				|  |  |                  strcat(path, contentsDir[j]->d_name);
 | 
	
		
			
				|  |  | -                displayed = printDir(contentsDir, path, nbFile, info, hiddenFile);
 | 
	
		
			
				|  |  | +                displayed = printDir(contentsDir, path, nbFile, hiddenFile);
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              else{
 | 
	
		
			
				|  |  |                  printf("%d  %ld  %s\n", info.st_mode, info.st_size, argv[i]);
 | 
	
	
		
			
				|  | @@ -114,7 +111,7 @@ void ls(int argc, char* argv[]){
 | 
	
		
			
				|  |  |          strcpy(path, buffer);
 | 
	
		
			
				|  |  |          strcat(path, "/");
 | 
	
		
			
				|  |  |          strcat(path, contentsDir[j]->d_name);
 | 
	
		
			
				|  |  | -        displayed = printDir(contentsDir, path, nbFile, info, hiddenFile);
 | 
	
		
			
				|  |  | +        displayed = printDir(contentsDir, path, nbFile, hiddenFile);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      printf("%d   %d\n", hiddenFile, checksubDir);
 |