ir: add trace UUID getter and setter
[babeltrace.git] / lib / ctf-writer / writer.c
index e9d747317825f7c0ec69fa0282c5fc90775a6346..9fd2f7ddee52d6ab3281a69d0440191c7d763613 100644 (file)
@@ -37,6 +37,7 @@
 #include <babeltrace/ref.h>
 #include <babeltrace/endian-internal.h>
 #include <babeltrace/compiler-internal.h>
+#include <babeltrace/compat/uuid-internal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/stat.h>
@@ -52,6 +53,7 @@ struct bt_ctf_writer *bt_ctf_writer_create(const char *path)
 {
        int ret;
        struct bt_ctf_writer *writer = NULL;
+       unsigned char uuid[16];
 
        if (!path) {
                goto error;
@@ -73,6 +75,13 @@ struct bt_ctf_writer *bt_ctf_writer_create(const char *path)
                goto error_destroy;
        }
 
+       /* Generate a UUID for this writer's trace */
+       uuid_generate(uuid);
+       ret = bt_ctf_trace_set_uuid(writer->trace, uuid);
+       if (ret) {
+               goto error_destroy;
+       }
+
        writer->trace->is_created_by_writer = 1;
        bt_object_set_parent(writer->trace, writer);
        bt_put(writer->trace);
This page took 0.022899 seconds and 4 git commands to generate.