From: Philippe Proulx Date: Fri, 13 Jan 2017 20:24:27 +0000 (-0500) Subject: ir: stream: add bt_ctf_stream_is_writer() X-Git-Tag: v2.0.0-pre1~581 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=98a4cbefe4c162067144bf5e1b7341c8dd8767bb ir: stream: add bt_ctf_stream_is_writer() This function indicates whether or not the stream is in "CTF writer mode", that is, its trace parent was created by a CTF writer object and it has an open file descriptor. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau --- diff --git a/formats/ctf/ir/stream.c b/formats/ctf/ir/stream.c index d4dbc447..5e9e1337 100644 --- a/formats/ctf/ir/stream.c +++ b/formats/ctf/ir/stream.c @@ -1000,3 +1000,17 @@ const char *bt_ctf_stream_get_name(struct bt_ctf_stream *stream) end: return name; } + +int bt_ctf_stream_is_writer(struct bt_ctf_stream *stream) +{ + int ret = -1; + + if (!stream) { + goto end; + } + + ret = (stream->pos.fd >= 0); + +end: + return ret; +} diff --git a/include/babeltrace/ctf-writer/stream.h b/include/babeltrace/ctf-writer/stream.h index f8ad7b83..56b6bff8 100644 --- a/include/babeltrace/ctf-writer/stream.h +++ b/include/babeltrace/ctf-writer/stream.h @@ -152,6 +152,8 @@ extern int bt_ctf_stream_set_packet_context( */ extern int bt_ctf_stream_flush(struct bt_ctf_stream *stream); +extern int bt_ctf_stream_is_writer(struct bt_ctf_stream *stream); + /* * bt_ctf_stream_get and bt_ctf_stream_put: increment and decrement the * stream's reference count.