summaryrefslogtreecommitdiff
path: root/src/bin/eolian/main.c
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2015-10-12 11:45:38 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-10-12 11:45:38 +0100
commit653e258eec564f4175bbf1c30bb687d27959ea83 (patch)
tree06841a8406654bc6184032c44df6d61c4d660795 /src/bin/eolian/main.c
parent89acf82bff2368dd310397fd788aa9db0d872716 (diff)
eolian generator: cleaner file write
Diffstat (limited to '')
-rw-r--r--src/bin/eolian/main.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/bin/eolian/main.c b/src/bin/eolian/main.c
index 61b2da6d6a..c213a5c5d8 100644
--- a/src/bin/eolian/main.c
+++ b/src/bin/eolian/main.c
@@ -94,9 +94,7 @@ _read_file(char *filename, Eina_Strbuf **buf)
94static Eina_Bool 94static Eina_Bool
95_write_file(char *filename, const Eina_Strbuf *buffer, Eina_Bool append) 95_write_file(char *filename, const Eina_Strbuf *buffer, Eina_Bool append)
96{ 96{
97 const char *data = eina_strbuf_string_get(buffer); 97 FILE *fd = fopen(filename, append ? "ab" : "wb");
98
99 FILE* fd = fopen(filename, append ? "ab" : "wb");
100 if (!fd) 98 if (!fd)
101 { 99 {
102 fprintf(stderr, "eolian: could not open '%s' for writing (%s)\n", 100 fprintf(stderr, "eolian: could not open '%s' for writing (%s)\n",
@@ -104,7 +102,8 @@ _write_file(char *filename, const Eina_Strbuf *buffer, Eina_Bool append)
104 return EINA_FALSE; 102 return EINA_FALSE;
105 } 103 }
106 104
107 if (data) fputs(data, fd); 105 if (eina_strbuf_length_get(buffer))
106 fwrite(eina_strbuf_string_get(buffer), 1, eina_strbuf_length_get(buffer), fd);
108 fclose(fd); 107 fclose(fd);
109 return EINA_TRUE; 108 return EINA_TRUE;
110} 109}