Skip to content

Commit 7119c81

Browse files
att
1 parent f6bb20b commit 7119c81

File tree

32 files changed

+259
-152
lines changed

32 files changed

+259
-152
lines changed

doTheWorld.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
#include "doTheWorld.h"
3+
4+
5+
int main(){
6+
DtwNamespace dtw = newDtwNamespace();
7+
8+
DtwPath * path = dtw.path.newPath("a/b/c/d.txt");
9+
char *dir = dtw.path.get_sub_dirs_from_index(path,0,2);
10+
printf("dir:%s\n",dir);
11+
dtw.path.free(path);
12+
13+
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
#include "doTheWorld.h"
3+
4+
5+
int main(){
6+
DtwNamespace dtw = newDtwNamespace();
7+
8+
DtwPath * path = dtw.path.newPath("a/b/c/d.txt");
9+
char *dir = dtw.path.get_sub_dirs_from_index(path,0,0);
10+
printf("dir:%s\n",dir);
11+
dtw.path.free(path);
12+
13+
14+
}

src/declaration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
#include "listage_wrappers/listage_wrappers.h"
5252
#include "monodimension_listage/monodimension_listage.h"
5353
#include "multidimension_listage/multidimension_listage.h"
54-
#include "path/path.h"
54+
#include "path/declaration.h"
5555
#include "tree/declarations.h"
5656

5757
#include "lockers/declaration.h"

src/definition.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@
2828
#include "monodimension_listage/monodimension_listage_linux.c"
2929
#include "monodimension_listage/monodimension_listage_win32.c"
3030
#include "multidimension_listage/multidimension_listage.c"
31-
#include "path/path.c"
32-
#include "path/setters.c"
33-
#include "path/getters.c"
34-
#include "path/index_dirs.c"
31+
#include "path/definition.h"
3532
#include "string_array/string_array.c"
3633
#include "tree/definitions.h"
3734

src/extras/extras.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,11 @@ long private_dtw_convert_index(long index,long size){
146146
}
147147

148148
if(converted_index >= size){
149-
return size -1;
149+
return -1;
150150
}
151+
151152
if(converted_index < 0){
152-
return 0;
153+
return -1;
153154
}
154155

155156
return converted_index;
File renamed without changes.

src/path/basic/basic.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
3+
struct DtwPath * newDtwPath(const char *path);
4+
5+
bool DtwPath_changed(struct DtwPath *self);
6+
7+
8+
9+
10+
void DtwPath_represent(struct DtwPath *self);
11+
12+
13+
14+
void DtwPath_free(struct DtwPath *self);

src/path/declaration.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#include "path.h"
2+
#include "basic/basic.h"
3+
#include "getters/getters.h"
4+
#include "setters/setters.h"
5+
#include "index/index.h"
6+
#include "meta/meta.h"

src/path/definition.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
#include "basic/basic.c"
3+
#include "getters/getters.c"
4+
#include "setters/setters.c"
5+
#include "index/index.c"
6+
#include "meta/meta.c"

0 commit comments

Comments
 (0)