src.ctf.fs: remove ctf_fs_file_create
[babeltrace.git] / src / plugins / ctf / fs-src / metadata.cpp
index 842b3eb749834df460e33ce74860b1d47bc3db29..bf905d3ae0975c3c88b29cdb30ca03424996eee9 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 #include "common/assert.h"
+#include "cpp-common/bt2s/make-unique.hpp"
 
 #include "../common/src/metadata/tsdl/decoder.hpp"
 #include "file.hpp"
@@ -35,16 +36,15 @@ end:
     return fp;
 }
 
-static ctf_fs_file::UP get_file(const char *trace_path, const bt2c::Logger& logger)
+static ctf_fs_file::UP get_file(const bt2c::CStringView trace_path, const bt2c::Logger& logger)
 {
-    auto file = ctf_fs_file_create(logger);
+    auto file = bt2s::make_unique<ctf_fs_file>(logger);
 
     if (!file) {
         goto error;
     }
 
-    g_string_append(file->path, trace_path);
-    g_string_append(file->path, G_DIR_SEPARATOR_S CTF_FS_METADATA_FILENAME);
+    file->path = fmt::format("{}" G_DIR_SEPARATOR_S CTF_FS_METADATA_FILENAME, trace_path);
 
     if (ctf_fs_file_open(file.get(), "rb")) {
         goto error;
@@ -69,7 +69,7 @@ int ctf_fs_metadata_set_trace_class(bt_self_component *self_comp, struct ctf_fs_
     decoder_config.clkClsCfg = clkClsCfg;
     decoder_config.create_trace_class = true;
 
-    const auto file = get_file(ctf_fs_trace->path->str, ctf_fs_trace->logger);
+    const auto file = get_file(ctf_fs_trace->path, ctf_fs_trace->logger);
     if (!file) {
         BT_CPPLOGE_SPEC(ctf_fs_trace->logger, "Cannot create metadata file object.");
         ret = -1;
@@ -93,6 +93,7 @@ int ctf_fs_metadata_set_trace_class(bt_self_component *self_comp, struct ctf_fs_
     ctf_fs_trace->metadata->trace_class =
         ctf_metadata_decoder_get_ir_trace_class(ctf_fs_trace->metadata->decoder.get());
     BT_ASSERT(!self_comp || ctf_fs_trace->metadata->trace_class);
+
     ctf_fs_trace->metadata->tc =
         ctf_metadata_decoder_borrow_ctf_trace_class(ctf_fs_trace->metadata->decoder.get());
     BT_ASSERT(ctf_fs_trace->metadata->tc);
@@ -100,20 +101,3 @@ int ctf_fs_metadata_set_trace_class(bt_self_component *self_comp, struct ctf_fs_
 end:
     return ret;
 }
-
-int ctf_fs_metadata_init(struct ctf_fs_metadata *)
-{
-    /* Nothing to initialize for the moment. */
-    return 0;
-}
-
-void ctf_fs_metadata_fini(struct ctf_fs_metadata *metadata)
-{
-    free(metadata->text);
-
-    if (metadata->trace_class) {
-        BT_TRACE_CLASS_PUT_REF_AND_RESET(metadata->trace_class);
-    }
-
-    metadata->decoder.reset();
-}
This page took 0.024585 seconds and 4 git commands to generate.