|
@@ -54,20 +54,12 @@ int printDir(struct dirent** contentsDir, char* path, int nbFile,
|
|
|
}
|
|
|
|
|
|
void ls(int argc, char* argv[]){
|
|
|
- char buffer[BUFFER_SIZE];
|
|
|
- char path[BUFFER_SIZE];
|
|
|
struct dirent** contentsDir;
|
|
|
struct stat info;
|
|
|
- int i = 1, j = 0, displayed = 0, nbFile, opt;
|
|
|
+ int i = 1, displayed = 0, nbFile, opt;
|
|
|
boolean hiddenFile = false;
|
|
|
boolean checksubDir = false;
|
|
|
|
|
|
- //Recuperation chemin actuel
|
|
|
- if (getcwd(buffer, sizeof (buffer)) == NULL) {
|
|
|
- addperror("Erreur getcwd()");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
//Gestion des options
|
|
|
while((opt = getopt(argc, argv, "aR")) != ERR){
|
|
|
switch(opt){
|
|
@@ -96,10 +88,7 @@ void ls(int argc, char* argv[]){
|
|
|
return;
|
|
|
}
|
|
|
printf("%s : \n\n", argv[i]);
|
|
|
- strcpy(path, buffer);
|
|
|
- strcat(path, "/");
|
|
|
- strcat(path, contentsDir[j]->d_name);
|
|
|
- displayed = printDir(contentsDir, path, nbFile, hiddenFile);
|
|
|
+ displayed = printDir(contentsDir, argv[i], nbFile, hiddenFile);
|
|
|
}
|
|
|
else{
|
|
|
printf("%d %ld %s\n", info.st_mode, info.st_size, argv[i]);
|
|
@@ -114,10 +103,7 @@ void ls(int argc, char* argv[]){
|
|
|
addperror("Erreur scandir()");
|
|
|
return;
|
|
|
}
|
|
|
- strcpy(path, buffer);
|
|
|
- strcat(path, "/");
|
|
|
- strcat(path, contentsDir[j]->d_name);
|
|
|
- displayed = printDir(contentsDir, path, nbFile, hiddenFile);
|
|
|
+ displayed = printDir(contentsDir, ".", nbFile, hiddenFile);
|
|
|
}
|
|
|
|
|
|
printf("%d %d\n", hiddenFile, checksubDir);
|