Store .obs and .json paths in stream struct

This commit is contained in:
Rodrigo Arias 2024-09-10 11:20:39 +02:00
parent 8e9cc34e5e
commit 3f6ec86890
3 changed files with 9 additions and 10 deletions

View File

@ -361,7 +361,7 @@ execute_sort_plan(struct sortplan *sp)
static int static int
stream_winsort(struct stream *stream, struct ring *r) stream_winsort(struct stream *stream, struct ring *r)
{ {
char *fn = stream->path; char *fn = stream->obspath;
int fd = open(fn, O_WRONLY); int fd = open(fn, O_WRONLY);
if (fd < 0) if (fd < 0)

View File

@ -158,25 +158,22 @@ stream_load(struct stream *stream, const char *tracedir, const char *relpath)
dbg("loading %s", stream->relpath); dbg("loading %s", stream->relpath);
char path_json[PATH_MAX]; if (path_append(stream->jsonpath, stream->path, "stream.json") != 0) {
char path_obs[PATH_MAX];
if (path_append(path_json, stream->path, "stream.json") != 0) {
err("path_append failed"); err("path_append failed");
return -1; return -1;
} }
if ((stream->meta = load_json(path_json)) == NULL) { if ((stream->meta = load_json(stream->jsonpath)) == NULL) {
err("load_json failed for: %s", path_json); err("load_json failed for: %s", stream->jsonpath);
return -1; 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"); err("path_append failed");
return -1; return -1;
} }
if (load_obs(stream, path_obs) != 0) { if (load_obs(stream, stream->obspath) != 0) {
err("load_obs failed"); err("load_obs failed");
return -1; return -1;
} }

View File

@ -28,8 +28,10 @@ struct stream {
int active; int active;
int unsorted; int unsorted;
char path[PATH_MAX]; char path[PATH_MAX]; /* To stream dir */
char relpath[PATH_MAX]; /* To tracedir */ 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 usize; /* Useful size for events */
int64_t offset; int64_t offset;