mirror of https://github.com/xfarrow/dircomp.git
Update dircomp.c
This commit is contained in:
parent
a53f763735
commit
244ff67d69
14
dircomp.c
14
dircomp.c
|
@ -28,12 +28,12 @@ void print_files_in_directory(char*, struct arguments);
|
||||||
|
|
||||||
int main(int argc, char* argv[]){
|
int main(int argc, char* argv[]){
|
||||||
struct arguments arguments = get_arguments(argc, argv);
|
struct arguments arguments = get_arguments(argc, argv);
|
||||||
|
|
||||||
if(arguments.h == true)
|
if(arguments.h == true)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
print_files_in_directory("/home/user", arguments);
|
print_files_in_directory("/home/user", arguments);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,21 +83,21 @@ void print_files_in_directory(char* directory, struct arguments arguments){
|
||||||
d = opendir(directory);
|
d = opendir(directory);
|
||||||
if (d) {
|
if (d) {
|
||||||
while ((dir = readdir(d)) != NULL) {
|
while ((dir = readdir(d)) != NULL) {
|
||||||
|
|
||||||
// is file
|
// is file
|
||||||
if (dir -> d_type == DT_REG)
|
if (dir -> d_type == DT_REG)
|
||||||
{
|
{
|
||||||
if(arguments.v == true)
|
if(arguments.v == true)
|
||||||
printf("Analyzing file: %s\n", dir -> d_name);
|
printf("Analyzing file: %s\n", dir -> d_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// is directory
|
// is directory
|
||||||
if (dir->d_type == DT_DIR)
|
if (dir -> d_type == DT_DIR)
|
||||||
{
|
{
|
||||||
if(arguments.r == true)
|
if(arguments.r == true)
|
||||||
print_files_in_directory(dir -> d_name, arguments); // todo, pass the pointer to reduce memory usage
|
print_files_in_directory(dir -> d_name, arguments); // todo, pass the pointer to reduce memory usage
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
closedir(d);
|
closedir(d);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue