From 3f6ec86890f55a7a6de0186e18a1ef6a1f432b69 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Date: Tue, 10 Sep 2024 11:20:39 +0200 Subject: [PATCH] Store .obs and .json paths in stream struct --- src/emu/ovnisort.c | 2 +- src/emu/stream.c | 13 +++++-------- src/emu/stream.h | 4 +++- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/emu/ovnisort.c b/src/emu/ovnisort.c index 812f091..1af8205 100644 --- a/src/emu/ovnisort.c +++ b/src/emu/ovnisort.c @@ -361,7 +361,7 @@ execute_sort_plan(struct sortplan *sp) static int stream_winsort(struct stream *stream, struct ring *r) { - char *fn = stream->path; + char *fn = stream->obspath; int fd = open(fn, O_WRONLY); if (fd < 0) diff --git a/src/emu/stream.c b/src/emu/stream.c index d0bee32..a589742 100644 --- a/src/emu/stream.c +++ b/src/emu/stream.c @@ -158,25 +158,22 @@ stream_load(struct stream *stream, const char *tracedir, const char *relpath) dbg("loading %s", stream->relpath); - char path_json[PATH_MAX]; - char path_obs[PATH_MAX]; - - if (path_append(path_json, stream->path, "stream.json") != 0) { + if (path_append(stream->jsonpath, stream->path, "stream.json") != 0) { err("path_append failed"); return -1; } - if ((stream->meta = load_json(path_json)) == NULL) { - err("load_json failed for: %s", path_json); + if ((stream->meta = load_json(stream->jsonpath)) == NULL) { + err("load_json failed for: %s", stream->jsonpath); return -1; } - if (path_append(path_obs, stream->path, "stream.obs") != 0) { + if (path_append(stream->obspath, stream->path, "stream.obs") != 0) { err("path_append failed"); return -1; } - if (load_obs(stream, path_obs) != 0) { + if (load_obs(stream, stream->obspath) != 0) { err("load_obs failed"); return -1; } diff --git a/src/emu/stream.h b/src/emu/stream.h index 8acee0c..16cb60a 100644 --- a/src/emu/stream.h +++ b/src/emu/stream.h @@ -28,8 +28,10 @@ struct stream { int active; int unsorted; - char path[PATH_MAX]; + char path[PATH_MAX]; /* To stream dir */ char relpath[PATH_MAX]; /* To tracedir */ + char obspath[PATH_MAX]; /* To obs file */ + char jsonpath[PATH_MAX]; /* To json file */ int64_t usize; /* Useful size for events */ int64_t offset;