MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / write_to_flow

Function write_to_flow

nanofi/src/api/nanofi.cpp:307–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305}
306
307flow_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

Callers 2

on_trigger_tailfilechunkFunction · 0.85
log_aggregateFunction · 0.85

Calls 2

generate_flowFunction · 0.85
free_flowfileFunction · 0.85

Tested by

no test coverage detected