@@ -1439,35 +1439,36 @@ typedef struct DtwHash{
14391439
14401440DtwHash * newDtwHash ();
14411441
1442- void DtwHash_digest_any (DtwHash * self ,unsigned char * content ,long size );
1442+ bool DtwHash_digest_any (DtwHash * self ,unsigned char * content ,long size );
14431443
1444- void DtwHash_digest_string (DtwHash * self , const char * content );
1444+ bool DtwHash_digest_string (DtwHash * self , const char * content );
14451445
14461446void DtwHash_digest_long (DtwHash * self ,long content );
14471447
14481448void DtwHash_digest_double (DtwHash * self ,double content );
14491449
14501450void DtwHash_digest_bool (DtwHash * self ,bool content );
14511451
1452- void DtwHash_digest_file (DtwHash * self , const char * path );
1452+ bool DtwHash_digest_file (DtwHash * self , const char * path );
14531453
1454- void DtwHash_digest_entity_last_modification (DtwHash * self , const char * path );
1454+ bool DtwHash_digest_entity_last_modification (DtwHash * self , const char * path );
14551455
1456+ bool DtwHash_digest_folder_by_last_modification (DtwHash * self ,const char * path );
14561457
1457- void DtwHash_digest_string_array (DtwHash * self ,DtwStringArray * element );
1458+ bool DtwHash_digest_folder_by_content (DtwHash * self ,const char * path );
14581459
1459- void DtwHash_digest_string_array_last_modifications (DtwHash * self ,DtwStringArray * element );
14601460
1461- void DtwHash_digest_string_array_last_modifications_adding_name (DtwHash * self ,DtwStringArray * element );
1461+ bool DtwHash_digest_string_array (DtwHash * self ,DtwStringArray * element );
14621462
1463+ bool DtwHash_digest_string_array_last_modifications (DtwHash * self ,DtwStringArray * element );
14631464
1464- void DtwHash_digest_string_array_content (DtwHash * self ,DtwStringArray * element );
1465+ bool DtwHash_digest_string_array_last_modifications_adding_name (DtwHash * self ,DtwStringArray * element );
14651466
1466- void DtwHash_digest_string_array_content_adding_name (DtwHash * self ,DtwStringArray * element );
14671467
1468- void DtwHash_digest_folder_by_last_modification (DtwHash * self ,const char * path );
1468+ bool DtwHash_digest_string_array_content (DtwHash * self ,DtwStringArray * element );
1469+
1470+ bool DtwHash_digest_string_array_content_adding_name (DtwHash * self ,DtwStringArray * element );
14691471
1470- void DtwHash_digest_folder_by_content (DtwHash * self ,const char * path );
14711472
14721473void DtwHash_free (DtwHash * self );
14731474
@@ -1900,20 +1901,20 @@ DtwResourceModule newDtwResourceModule();
19001901
19011902typedef struct DtwHashModule {
19021903 DtwHash * (* newHash )();
1903- void (* digest_any )(DtwHash * self ,unsigned char * content ,long size );
1904- void (* digest_string )(DtwHash * self , const char * content );
1904+ bool (* digest_any )(DtwHash * self ,unsigned char * content ,long size );
1905+ bool (* digest_string )(DtwHash * self , const char * content );
19051906 void (* digest_long )(DtwHash * self ,long content );
19061907 void (* digest_double )(DtwHash * self ,double content );
19071908 void (* digest_bool )(DtwHash * self ,bool content );
1908- void (* digest_file )(DtwHash * self , const char * path );
1909- void (* digest_entity_last_modification )(DtwHash * self , const char * path );
1910- void (* digest_string_array )(DtwHash * self ,DtwStringArray * element );
1911- void (* digest_string_array_last_modifications )(DtwHash * self ,DtwStringArray * element );
1912- void (* digest_string_array_last_modifications_adding_name )(DtwHash * self ,DtwStringArray * element );
1913- void (* digest_string_array_content )(DtwHash * self ,DtwStringArray * element );
1914- void (* digest_string_array_content_adding_name )(DtwHash * self ,DtwStringArray * element );
1915- void (* digest_folder_by_last_modification )(DtwHash * self ,const char * path );
1916- void (* digest_folder_by_content )(DtwHash * self ,const char * path );
1909+ bool (* digest_file )(DtwHash * self , const char * path );
1910+ bool (* digest_entity_last_modification )(DtwHash * self , const char * path );
1911+ bool (* digest_string_array )(DtwHash * self ,DtwStringArray * element );
1912+ bool (* digest_string_array_last_modifications )(DtwHash * self ,DtwStringArray * element );
1913+ bool (* digest_string_array_last_modifications_adding_name )(DtwHash * self ,DtwStringArray * element );
1914+ bool (* digest_string_array_content )(DtwHash * self ,DtwStringArray * element );
1915+ bool (* digest_string_array_content_adding_name )(DtwHash * self ,DtwStringArray * element );
1916+ bool (* digest_folder_by_last_modification )(DtwHash * self ,const char * path );
1917+ bool (* digest_folder_by_content )(DtwHash * self ,const char * path );
19171918 void (* free )(DtwHash * self );
19181919
19191920}DtwHashModule ;
@@ -10316,20 +10317,21 @@ DtwHash * newDtwHash(){
1031610317 return self ;
1031710318}
1031810319
10319- void DtwHash_digest_any (DtwHash * self ,unsigned char * content ,long size ){
10320+ bool DtwHash_digest_any (DtwHash * self ,unsigned char * content ,long size ){
1032010321 if (content == NULL ){
10321- return ;
10322+ return false ;
1032210323 }
1032310324 char * generated = dtw_generate_sha_from_any (content ,size );
1032410325 char result [300 ] = {0 };
1032510326 sprintf (result ,"%s%s" ,self -> hash ,generated );
1032610327 free (generated );
1032710328 free (self -> hash );
1032810329 self -> hash = dtw_generate_sha_from_string (result );
10330+ return true;
1032910331}
1033010332
10331- void DtwHash_digest_string (DtwHash * self , const char * content ){
10332- DtwHash_digest_any (self ,(unsigned char * )content , (long )strlen (content ));
10333+ bool DtwHash_digest_string (DtwHash * self , const char * content ){
10334+ return DtwHash_digest_any (self ,(unsigned char * )content , (long )strlen (content ));
1033310335}
1033410336
1033510337void DtwHash_digest_long (DtwHash * self ,long content ){
@@ -10350,73 +10352,104 @@ void DtwHash_digest_bool(DtwHash * self,bool content){
1035010352 DtwHash_digest_string (self ,formated );
1035110353}
1035210354
10353- void DtwHash_digest_file (DtwHash * self , const char * path ){
10355+ bool DtwHash_digest_file (DtwHash * self , const char * path ){
1035410356
1035510357 long size ;
1035610358 unsigned char * content = dtw_load_binary_content (path ,& size );
10359+ if (!content ){
10360+ return false;
10361+ }
1035710362 DtwHash_digest_any (self ,content ,size );
1035810363 free (content );
10364+ return true;
1035910365}
1036010366
10361- void DtwHash_digest_entity_last_modification (DtwHash * self , const char * path ){
10367+ bool DtwHash_digest_entity_last_modification (DtwHash * self , const char * path ){
1036210368 long last_modification = dtw_get_entity_last_motification_in_unix (path );
10369+ if (last_modification == -1 ){
10370+ return false;
10371+ }
1036310372 DtwHash_digest_long (self ,last_modification );
10373+ return true;
1036410374}
1036510375
1036610376
10367- void DtwHash_digest_string_array (DtwHash * self ,DtwStringArray * element ){
10377+ bool DtwHash_digest_string_array (DtwHash * self ,DtwStringArray * element ){
10378+ if (element -> size == 0 ){
10379+ return false;
10380+ }
1036810381 DtwStringArray * clone = DtwStringArray_clone (element );
1036910382 DtwStringArray_sort (clone );
1037010383
1037110384 for (int i = 0 ; i < clone -> size ; i ++ ){
1037210385 DtwHash_digest_string (self ,clone -> strings [i ]);
1037310386 }
1037410387 DtwStringArray_free (clone );
10388+ return true;
1037510389}
1037610390
10377- void DtwHash_digest_string_array_last_modifications (DtwHash * self ,DtwStringArray * element ){
10391+ bool DtwHash_digest_string_array_last_modifications (DtwHash * self ,DtwStringArray * element ){
10392+ if (element -> size == 0 ){
10393+ return false;
10394+ }
1037810395 DtwStringArray * clone = DtwStringArray_clone (element );
1037910396 DtwStringArray_sort (clone );
1038010397 for (int i = 0 ; i < clone -> size ; i ++ ){
1038110398 DtwHash_digest_entity_last_modification (self , clone -> strings [i ]);
1038210399 }
1038310400 DtwStringArray_free (clone );
10384-
10401+ return true;
1038510402}
1038610403
10387- void DtwHash_digest_string_array_last_modifications_adding_name (DtwHash * self ,DtwStringArray * element ){
10404+ bool DtwHash_digest_string_array_last_modifications_adding_name (DtwHash * self ,DtwStringArray * element ){
10405+ if (element -> size == 0 ){
10406+ return false;
10407+ }
1038810408 DtwStringArray * clone = DtwStringArray_clone (element );
1038910409 DtwStringArray_sort (clone );
1039010410 for (int i = 0 ; i < clone -> size ; i ++ ){
1039110411 DtwHash_digest_string (self ,clone -> strings [i ]);
1039210412 DtwHash_digest_entity_last_modification (self , clone -> strings [i ]);
1039310413 }
1039410414 DtwStringArray_free (clone );
10415+ return true;
1039510416}
1039610417
1039710418
10398- void DtwHash_digest_string_array_content (DtwHash * self ,DtwStringArray * element ){
10419+ bool DtwHash_digest_string_array_content (DtwHash * self ,DtwStringArray * element ){
10420+ if (element -> size == 0 ){
10421+ return false;
10422+ }
1039910423 DtwStringArray * clone = DtwStringArray_clone (element );
1040010424 DtwStringArray_sort (clone );
1040110425 for (int i = 0 ; i < clone -> size ; i ++ ){
1040210426 DtwHash_digest_file (self ,clone -> strings [i ]);
1040310427 }
1040410428 DtwStringArray_free (clone );
10429+ return true;
1040510430}
1040610431
10407- void DtwHash_digest_string_array_content_adding_name (DtwHash * self ,DtwStringArray * element ){
10432+ bool DtwHash_digest_string_array_content_adding_name (DtwHash * self ,DtwStringArray * element ){
10433+ if (element -> size == 0 ){
10434+ return false;
10435+ }
1040810436 DtwStringArray * clone = DtwStringArray_clone (element );
1040910437 DtwStringArray_sort (clone );
1041010438 for (int i = 0 ; i < clone -> size ; i ++ ){
1041110439 DtwHash_digest_string (self ,clone -> strings [i ]);
1041210440 DtwHash_digest_file (self ,clone -> strings [i ]);
1041310441 }
1041410442 DtwStringArray_free (clone );
10443+ return true;
1041510444}
1041610445
1041710446
10418- void DtwHash_digest_folder_by_last_modification (DtwHash * self ,const char * path ){
10447+ bool DtwHash_digest_folder_by_last_modification (DtwHash * self ,const char * path ){
1041910448 DtwStringArray * folder = dtw_list_all_recursively (path ,DTW_NOT_CONCAT_PATH );
10449+ if (folder -> size == 0 ){
10450+ DtwStringArray_free (folder );
10451+ return false;
10452+ }
1042010453 DtwStringArray_sort (folder );
1042110454 for (int i = 0 ; i < folder -> size ; i ++ ){
1042210455 DtwHash_digest_string (self ,folder -> strings [i ]);
@@ -10426,10 +10459,16 @@ void DtwHash_digest_folder_by_last_modification(DtwHash *self,const char *path){
1042610459 free (formated_path );
1042710460 }
1042810461 DtwStringArray_free (folder );
10462+ return true;
1042910463}
1043010464
10431- void DtwHash_digest_folder_by_content (DtwHash * self ,const char * path ){
10465+ bool DtwHash_digest_folder_by_content (DtwHash * self ,const char * path ){
10466+
1043210467 DtwStringArray * folder = dtw_list_all_recursively (path ,DTW_NOT_CONCAT_PATH );
10468+ if (folder -> size == 0 ){
10469+ DtwStringArray_free (folder );
10470+ return false;
10471+ }
1043310472 DtwStringArray_sort (folder );
1043410473 for (int i = 0 ; i < folder -> size ; i ++ ){
1043510474 DtwHash_digest_string (self ,folder -> strings [i ]);
@@ -10438,6 +10477,7 @@ void DtwHash_digest_folder_by_content(DtwHash *self,const char *path){
1043810477 free (formated_path );
1043910478 }
1044010479 DtwStringArray_free (folder );
10480+ return true;
1044110481}
1044210482
1044310483void DtwHash_free (DtwHash * self ){
0 commit comments