@@ -7283,20 +7283,25 @@ char *DtwPath_get_sub_dirs_from_index(DtwPath *self, int start, int end){
72837283 char * dir = DtwPath_get_dir (self );
72847284 int dirs_string_size = (int )strlen (dir );
72857285 int total_dirs = 0 ;
7286+ bool start_defined = false;
7287+ bool end_defined = false;
72867288 int start_point = 0 ;
72877289 int end_point = dirs_string_size ;
72887290
72897291 for (int i = 0 ;i < dirs_string_size ;i ++ ){
72907292 char current = dir [i ];
72917293 if (current == '/' || current == '\\' ){
72927294 total_dirs += 1 ;
7295+ continue ;
72937296 }
7294- if (total_dirs == converted_start_index ){
7297+ if (total_dirs == converted_start_index && ! start_defined ){
72957298 start_point = i ;
7299+ start_defined = true;
72967300 }
72977301
7298- if (total_dirs == (converted_end_index + 1 )){
7302+ if (total_dirs == (converted_end_index + 1 )&& ! end_defined ){
72997303 end_point = i ;
7304+ end_defined = true;
73007305 }
73017306 }
73027307 char * buffer = private_dtw_sub_str (dir ,start_point ,end_point );
@@ -7398,7 +7403,7 @@ void DtwPath_remove_sub_dirs_at_index(DtwPath *self, int start, int end){
73987403 free (buffer );
73997404 }
74007405
7401- if (! start_dirs ){
7406+ if (start_dirs == NULL ){
74027407 DtwPath_set_dir (self ,end_dirs );
74037408 }
74047409
@@ -7412,10 +7417,7 @@ void DtwPath_remove_sub_dirs_at(DtwPath *self,const char *str){
74127417 }
74137418
74147419 int start = private_dtw_count_dirs_before (current_dir ,index );
7415- int end = private_dtw_count_dirs_before (current_dir ,index + (int )strlen (str ));
7416- printf ("start %d\n" ,start );
7417-
7418- printf ("end %d\n" ,end );
7420+ int end = private_dtw_count_dirs_before (current_dir ,index + (int )strlen (str ));;
74197421 DtwPath_remove_sub_dirs_at_index (self , start , end - 1 );
74207422}
74217423
0 commit comments