+
+ if (cfg->cmd_data.print_ctf_metadata.output_path->len > 0) {
+ out_stream =
+ fopen(cfg->cmd_data.print_ctf_metadata.output_path->str,
+ "w");
+ if (!out_stream) {
+ ret = -1;
+ BT_LOGE_ERRNO("Cannot open file for writing",
+ ": path=\"%s\"",
+ cfg->cmd_data.print_ctf_metadata.output_path->str);
+ goto end;
+ }
+ }
+
+ ret = fprintf(out_stream, "%s\n", metadata_text);
+ if (ret < 0) {
+ BT_LOGE("Cannot write whole metadata text to output stream: "
+ "ret=%d", ret);
+ }
+