| 1174 | } |
| 1175 | |
| 1176 | int tpl_save_as(const tpl_t* tpl, const char* filename) |
| 1177 | { |
| 1178 | FILE *fp = fopen(filename, "wb"); |
| 1179 | |
| 1180 | if (fp != NULL) |
| 1181 | { |
| 1182 | int len = tpl_length(tpl); |
| 1183 | int n; |
| 1184 | char *content = (char *)acl_mymalloc(len + 1); |
| 1185 | |
| 1186 | tpl_get_content(tpl, content); |
| 1187 | |
| 1188 | n = (int) fwrite(content, len, 1, fp); |
| 1189 | if (n != 1) |
| 1190 | { |
| 1191 | (void)fclose(fp); |
| 1192 | acl_myfree(content); |
| 1193 | return TPL_WRITE_ERROR; |
| 1194 | } |
| 1195 | (void)fclose(fp); |
| 1196 | |
| 1197 | acl_myfree(content); |
| 1198 | return TPL_OK; |
| 1199 | } |
| 1200 | return TPL_OPEN_ERROR; |
| 1201 | } |
| 1202 | |
| 1203 | #ifdef WIN32 |
| 1204 | #define write _write |
no test coverage detected
searching dependent graphs…