mirror of https://github.com/xfarrow/dircomp.git
Default now compares files' bytes
This commit is contained in:
parent
109827a620
commit
fe7d1ec604
|
@ -22,6 +22,6 @@ The options are as follows:
|
||||||
-r Recursive
|
-r Recursive
|
||||||
-v Verbose
|
-v Verbose
|
||||||
-f Fast. Halt as soon as the directories are found to be not equal
|
-f Fast. Halt as soon as the directories are found to be not equal
|
||||||
-b Byte-by-byte file comparison (default compares their hashes)
|
-d Comparison by digest
|
||||||
-h Print this help and quit
|
-h Print this help and quit
|
||||||
```
|
```
|
||||||
|
|
16
dircomp.c
16
dircomp.c
|
@ -49,7 +49,7 @@ struct arguments get_arguments(int argc, char **argv)
|
||||||
return provided_arguments;
|
return provided_arguments;
|
||||||
}
|
}
|
||||||
char option;
|
char option;
|
||||||
while ((option = getopt(argc, argv, "rvhfb")) != -1)
|
while ((option = getopt(argc, argv, "rvhfd")) != -1)
|
||||||
{
|
{
|
||||||
switch (option)
|
switch (option)
|
||||||
{
|
{
|
||||||
|
@ -65,8 +65,8 @@ struct arguments get_arguments(int argc, char **argv)
|
||||||
case 'f':
|
case 'f':
|
||||||
provided_arguments.f = true;
|
provided_arguments.f = true;
|
||||||
break;
|
break;
|
||||||
case 'b':
|
case 'd':
|
||||||
provided_arguments.b = true;
|
provided_arguments.d = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,10 +140,10 @@ bool analyze_directories(char* directory_to_analyze_1, char* directory_to_analyz
|
||||||
{
|
{
|
||||||
fullpath_helper2 = combine_path(directory_to_analyze_1, element->d_name);
|
fullpath_helper2 = combine_path(directory_to_analyze_1, element->d_name);
|
||||||
|
|
||||||
if(arguments->b)
|
if(arguments->d)
|
||||||
file_equality_result = byte_by_byte_file_comparison(fullpath_helper, fullpath_helper2);
|
|
||||||
else
|
|
||||||
file_equality_result = hash_by_hash_file_comparison(fullpath_helper, fullpath_helper2);
|
file_equality_result = hash_by_hash_file_comparison(fullpath_helper, fullpath_helper2);
|
||||||
|
else
|
||||||
|
file_equality_result = byte_by_byte_file_comparison(fullpath_helper, fullpath_helper2);
|
||||||
|
|
||||||
|
|
||||||
if (file_equality_result != 1)
|
if (file_equality_result != 1)
|
||||||
|
@ -358,7 +358,7 @@ unsigned char* sha1(char *filename)
|
||||||
EVP_MD_CTX *mdctx; // envelope context
|
EVP_MD_CTX *mdctx; // envelope context
|
||||||
const EVP_MD *md; // envelope mode (SHA1)
|
const EVP_MD *md; // envelope mode (SHA1)
|
||||||
unsigned char *hash = malloc(EVP_MAX_MD_SIZE * sizeof(unsigned char)); // result will be here
|
unsigned char *hash = malloc(EVP_MAX_MD_SIZE * sizeof(unsigned char)); // result will be here
|
||||||
unsigned int digest_len, i;
|
unsigned int digest_len;
|
||||||
size_t bytes; // how many bytes we have actually read from fread
|
size_t bytes; // how many bytes we have actually read from fread
|
||||||
unsigned char databuffer[BYTES_TO_READ_AT_ONCE];
|
unsigned char databuffer[BYTES_TO_READ_AT_ONCE];
|
||||||
|
|
||||||
|
@ -413,6 +413,6 @@ void print_help(void)
|
||||||
printf(" -r \t\t Recursive\n");
|
printf(" -r \t\t Recursive\n");
|
||||||
printf(" -v \t\t Verbose\n");
|
printf(" -v \t\t Verbose\n");
|
||||||
printf(" -f \t\t Fast. Halt as soon as the directories are found to be not equal\n");
|
printf(" -f \t\t Fast. Halt as soon as the directories are found to be not equal\n");
|
||||||
printf(" -b \t\t Byte-by-byte file comparison (default compares their hashes)\n");
|
printf(" -d \t\t Comparison by digest\n");
|
||||||
printf(" -h \t\t Print this help and quit\n");
|
printf(" -h \t\t Print this help and quit\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ struct arguments{
|
||||||
bool v; // verbose
|
bool v; // verbose
|
||||||
bool h; // help
|
bool h; // help
|
||||||
bool f; // fast
|
bool f; // fast
|
||||||
bool b; // byte-by-byte comparison
|
bool d; // comparison by digest
|
||||||
};
|
};
|
||||||
|
|
||||||
struct arguments get_arguments(int, char**);
|
struct arguments get_arguments(int, char**);
|
||||||
|
|
Loading…
Reference in New Issue