CTF-IR: Support unnamed streams
[babeltrace.git] / formats / ctf / writer / writer.c
index 54eab39bb54d31fa251a74125f8a0d75222679ba..7b59d16cf1b71745883269d2287401003816e31d 100644 (file)
@@ -290,10 +290,23 @@ int create_stream_file(struct bt_ctf_writer *writer,
        int fd;
        GString *filename = g_string_new(stream->stream_class->name->str);
 
+       if (stream->stream_class->name->len == 0) {
+               int64_t ret;
+
+               ret = bt_ctf_stream_class_get_id(stream->stream_class);
+               if (ret < 0) {
+                       fd = -1;
+                       goto error;
+               }
+
+               g_string_printf(filename, "stream_%" PRId64, ret);
+       }
+
        g_string_append_printf(filename, "_%" PRIu32, stream->id);
        fd = openat(writer->trace_dir_fd, filename->str,
                O_RDWR | O_CREAT | O_TRUNC,
                S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+error:
        g_string_free(filename, TRUE);
        return fd;
 }
This page took 0.022549 seconds and 4 git commands to generate.