Update dircomp.c

This commit is contained in:
alessandro ferro 2023-04-17 09:26:28 +02:00
parent b0c4cb9ddc
commit 0a0f296ad9
1 changed files with 13 additions and 9 deletions

View File

@ -99,7 +99,7 @@ bool analyze_directories(char* directory_to_analyze_1, char* directory_to_analyz
// Is file
if (element->d_type == DT_REG)
{
// Check wether it exists in directory2
// Check whether it exists in directory2
fullpath_file_helper = malloc(sizeof(char) * (strlen(directory_to_analyze_2) + strlen(element->d_name) + 2) );
strcpy(fullpath_file_helper, directory_to_analyze_2);
strcat(fullpath_file_helper, "/");
@ -170,7 +170,7 @@ bool analyze_directories(char* directory_to_analyze_1, char* directory_to_analyz
{
continue;
}
// Check wether a folder with the same name exists in directory2
// Check whether a folder with the same name exists in directory2
fullpath_file_helper = malloc(sizeof(char) * (strlen(directory_to_analyze_2) + strlen(element->d_name) + 2) );
strcpy(fullpath_file_helper, directory_to_analyze_2);
strcat(fullpath_file_helper, "/");
@ -210,10 +210,13 @@ bool analyze_directories(char* directory_to_analyze_1, char* directory_to_analyz
strcat(subdirectory2, "/");
strcat(subdirectory2, element->d_name);
is_directory_equal = analyze_directories(subdirectory1, subdirectory2, arguments) && is_directory_equal;
// Interrupt recursion if -f option is set
if(arguments->f == true && is_directory_equal == false){
break;
free( fullpath_file_helper );
free( directory_to_analyze_1 );
free( directory_to_analyze_2 );
closedir( directory );
return false;
}
}
}
@ -260,6 +263,7 @@ bool analyze_directories(char* directory_to_analyze_1, char* directory_to_analyz
{
free( directory_to_analyze_1 );
free( directory_to_analyze_2 );
closedir( directory );
return false;
}
}