Added some comments to the code
This commit is contained in:
parent
6abb041631
commit
94c62f3d6b
9 changed files with 50 additions and 37 deletions
|
|
@ -9,12 +9,12 @@
|
|||
void changeCurrentWorkDir(char *arg[]){
|
||||
DIR *d;
|
||||
struct dirent *dir;
|
||||
d = opendir(arg[1]);
|
||||
if(d == NULL){
|
||||
d = opendir(arg[1]); //Try to open directory
|
||||
if(d == NULL){ //Check if directory exists
|
||||
printf("Folder not found.\n");
|
||||
return;
|
||||
} else {
|
||||
chdir(arg[1]);
|
||||
chdir(arg[1]); //If directory exists, change workpath
|
||||
}
|
||||
closedir(d);
|
||||
closedir(d); //Close directory
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "help.h"
|
||||
|
||||
//Print the help
|
||||
void outputHelp(){
|
||||
printf("usage: netbenixCMD [option]\n");
|
||||
printf("Options:\n");
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ void showDirectory(char *arg[]){
|
|||
struct dirent *dir;
|
||||
char path[PATH_MAX];
|
||||
|
||||
d = opendir(arg[1]);
|
||||
if(d == NULL){
|
||||
d = opendir(arg[1]); //Try to open directory
|
||||
if(d == NULL){ //Check if directory exists
|
||||
printf("Folder not found.\n");
|
||||
return;
|
||||
}
|
||||
realpath(arg[1], path);
|
||||
realpath(arg[1], path); //Get the absolute path of the directory
|
||||
if(d){
|
||||
while((dir = readdir(d))){
|
||||
if(dir->d_type == 8){ //IF IS FILE
|
||||
|
|
@ -43,6 +43,6 @@ void showDirectory(char *arg[]){
|
|||
printf("%s\n", dir->d_name);
|
||||
}
|
||||
}
|
||||
closedir(d);
|
||||
closedir(d); //Close directory
|
||||
}
|
||||
}
|
||||
Reference in a new issue