| 305 | } |
| 306 | |
| 307 | flow_file_record * write_to_flow(const char * buff, size_t count, processor_context * ctx) { |
| 308 | if (!ctx) { |
| 309 | return NULL; |
| 310 | } |
| 311 | |
| 312 | flow_file_record * ffr = generate_flow(ctx); |
| 313 | |
| 314 | if (ffr == NULL) { |
| 315 | printf("Could not generate flow file\n"); |
| 316 | return NULL; |
| 317 | } |
| 318 | |
| 319 | FILE * ffp = fopen(ffr->contentLocation, "wb"); |
| 320 | if (!ffp) { |
| 321 | printf("Cannot open flow file at path %s to write content to.\n", ffr->contentLocation); |
| 322 | free_flowfile(ffr); |
| 323 | return NULL; |
| 324 | } |
| 325 | |
| 326 | size_t ret = fwrite(buff, 1, count, ffp); |
| 327 | if (ret < count) { |
| 328 | fclose(ffp); |
| 329 | free_flowfile(ffr); |
| 330 | return NULL; |
| 331 | } |
| 332 | fseek(ffp, 0, SEEK_END); |
| 333 | ffr->size = ftell(ffp); |
| 334 | fclose(ffp); |
| 335 | return ffr; |
| 336 | } |
| 337 | |
| 338 | /** |
| 339 | * Reclaims memory associated with a flow file object |
no test coverage detected