- if (stream->stream_class->name->len == 0) {
- int64_t ret;
-
- ret = bt_ctf_stream_class_get_id(stream->stream_class);
- if (ret < 0) {
- BT_LOGW("Cannot get stream class's ID: "
- "stream-class-addr=%p, "
- "stream-class-name=\"%s\"",
- stream->stream_class,
- stream->stream_class->name->str);
- fd = -1;
- goto end;
+ if (stream->name && stream->name->len > 0) {
+ /* Use stream name's base name as prefix */
+ gchar *basename = g_path_get_basename(stream->name->str);
+
+ assert(basename);
+
+ if (strcmp(basename, G_DIR_SEPARATOR_S) == 0) {
+ g_string_assign(filename, "stream");
+ } else {
+ g_string_assign(filename, basename);
+ }
+
+ g_free(basename);
+ goto append_ids;
+ }
+
+ if (stream->stream_class->name &&
+ stream->stream_class->name->len > 0) {
+ /* Use stream class name's base name as prefix */
+ gchar *basename =
+ g_path_get_basename(stream->stream_class->name->str);
+
+ assert(basename);
+
+ if (strcmp(basename, G_DIR_SEPARATOR_S) == 0) {
+ g_string_assign(filename, "stream");
+ } else {
+ g_string_assign(filename, basename);