Skip to content

Commit 6f7671d

Browse files
improved write mode
1 parent d70d27a commit 6f7671d

6 files changed

Lines changed: 37 additions & 4 deletions

src/imports/imports.func_declaration.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define silverchain_func_declaration
44
#include "../algo/func_declaration.algo.h"
55
#include "../generation/func_declaration.generation.h"
6+
#include "../../src/io/func_declaration.io_functions.h"
67
#include "../tag/func_declaration.tag.h"
78
#include "../taglist/func_declaration.taglist.h"
89
#endif

src/imports/imports.func_definition.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define silverchain_func_definition
44
#include "../algo/func_definition.algo.c"
55
#include "../generation/func_definition.generation.c"
6+
#include "../../src/io/func_definition.io_functions.c"
67
#include "../tag/func_definition.tag.c"
78
#include "../taglist/func_definition.taglist.c"
89
#endif
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
//silver_chain_scope_start
3+
//mannaged by silver chain
4+
#include "../../src/imports/imports.globals.h"
5+
//silver_chain_scope_end
6+
7+
void write_element_if_not_equal(const char *path,const char *content);
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
//silver_chain_scope_start
3+
//mannaged by silver chain
4+
#include "../../src/imports/imports.func_declaration.h"
5+
//silver_chain_scope_end
6+
7+
8+
void write_element_if_not_equal(const char *path,const char *content){
9+
char *old = dtw.load_string_file_content(path);
10+
if(old){
11+
if(strcmp(old, content) !=0){
12+
dtw.write_string_file_content(path,content);
13+
}
14+
free(old);
15+
return;
16+
}
17+
dtw.write_string_file_content(path,content);
18+
19+
20+
21+
22+
23+
}

src/tag/func_definition.tag.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ void Tag_create_module_file(
4848

4949
stack.format(final_text,"#endif\n");
5050

51-
dtw.write_string_file_content(final_text_path->rendered_text,final_text->rendered_text);
51+
52+
write_element_if_not_equal(final_text_path->rendered_text,final_text->rendered_text);
5253
UniversalGarbage_free(garbage);
5354

5455
}
@@ -75,7 +76,7 @@ void replace_import_file(const char *current_file_path,const char *module_path){
7576
if(start_scope_index == -1){
7677
//means its not implemented
7778
stack.self_insert_at(file_content_stack,0,text_to_insert->rendered_text);
78-
dtw.write_string_file_content(current_file_path,file_content_stack->rendered_text);
79+
write_element_if_not_equal(current_file_path,file_content_stack->rendered_text);
7980
UniversalGarbage_free(garbage);
8081
return;;
8182
}
@@ -90,7 +91,7 @@ void replace_import_file(const char *current_file_path,const char *module_path){
9091
//replace the content
9192
stack.self_pop(file_content_stack,start_scope_index,end_scope_index+end_scope_size-1);
9293
stack.self_insert_at(file_content_stack,start_scope_index,text_to_insert->rendered_text);
93-
dtw.write_string_file_content(current_file_path,file_content_stack->rendered_text);
94+
write_element_if_not_equal(current_file_path,file_content_stack->rendered_text);
9495
UniversalGarbage_free(garbage);
9596
}
9697

src/tag/types.tag.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "../imports/imports.consts.h"
55
//silver_chain_scope_end
66

7-
typedef struct{
7+
typedef struct Tag{
88
char *name;
99
int priority;
1010
DtwStringArray *itens;

0 commit comments

Comments
 (0)