Rename bt_ctf_X -> bt_X, maintain backward compat. for pre-2.0 CTF writer
[babeltrace.git] / plugins / ctf / fs-src / metadata.c
index 91465cb98bf6d7462acc0747599368616df4cf16..231d946ce791d15222bff4fa5b0d429057ae805d 100644 (file)
@@ -31,6 +31,7 @@
 #include <glib.h>
 #include <babeltrace/compat/uuid-internal.h>
 #include <babeltrace/compat/memstream-internal.h>
+#include <babeltrace/babeltrace.h>
 
 #include "fs.h"
 #include "file.h"
 #define BT_LOG_TAG "PLUGIN-CTF-FS-METADATA-SRC"
 #include "logging.h"
 
-#define NSEC_PER_SEC 1000000000LL
-
 BT_HIDDEN
 FILE *ctf_fs_metadata_open_file(const char *trace_path)
 {
-       GString *metadata_path = g_string_new(trace_path);
+       GString *metadata_path;
        FILE *fp = NULL;
 
+       metadata_path = g_string_new(trace_path);
        if (!metadata_path) {
-               goto error;
+               goto end;
        }
 
-       g_string_append(metadata_path, "/" CTF_FS_METADATA_FILENAME);
+       g_string_append(metadata_path, G_DIR_SEPARATOR_S CTF_FS_METADATA_FILENAME);
        fp = fopen(metadata_path->str, "rb");
-       if (!fp) {
-               goto error;
-       }
-
-       goto end;
-
-error:
-       if (fp) {
-               fclose(fp);
-               fp = NULL;
-       }
-
-end:
        g_string_free(metadata_path, TRUE);
+end:
        return fp;
 }
 
@@ -80,7 +68,7 @@ static struct ctf_fs_file *get_file(const char *trace_path)
        }
 
        g_string_append(file->path, trace_path);
-       g_string_append(file->path, "/" CTF_FS_METADATA_FILENAME);
+       g_string_append(file->path, G_DIR_SEPARATOR_S CTF_FS_METADATA_FILENAME);
 
        if (ctf_fs_file_open(file, "rb")) {
                goto error;
@@ -99,12 +87,15 @@ end:
 }
 
 int ctf_fs_metadata_set_trace(struct ctf_fs_trace *ctf_fs_trace,
-               struct metadata_overrides *overrides)
+               struct ctf_fs_metadata_config *config)
 {
        int ret = 0;
        struct ctf_fs_file *file = NULL;
        struct ctf_metadata_decoder *metadata_decoder = NULL;
-       int64_t clock_offset_adjustment = 0;
+       struct ctf_metadata_decoder_config decoder_config = {
+               .clock_class_offset_s = config ? config->clock_class_offset_s : 0,
+               .clock_class_offset_ns = config ? config->clock_class_offset_ns : 0,
+       };
 
        file = get_file(ctf_fs_trace->path->str);
        if (!file) {
@@ -113,12 +104,8 @@ int ctf_fs_metadata_set_trace(struct ctf_fs_trace *ctf_fs_trace,
                goto end;
        }
 
-       if (overrides) {
-               clock_offset_adjustment =
-                       overrides->clock_offset_s * NSEC_PER_SEC +
-                       overrides->clock_offset_ns;
-       }
-       metadata_decoder = ctf_metadata_decoder_create(clock_offset_adjustment,
+       metadata_decoder = ctf_metadata_decoder_create(
+               config ? &decoder_config : NULL,
                ctf_fs_trace->name->str);
        if (!metadata_decoder) {
                BT_LOGE("Cannot create metadata decoder object");
This page took 0.025744 seconds and 4 git commands to generate.