From 94fb1117dd8c32dd4732b792300f1b6b3cb6af8f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 2 Nov 2022 15:00:13 +0200 Subject: Add diag_buffer::is_open() --- libbuild2/diagnostics.hxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libbuild2/diagnostics.hxx b/libbuild2/diagnostics.hxx index 1659a09..e619f86 100644 --- a/libbuild2/diagnostics.hxx +++ b/libbuild2/diagnostics.hxx @@ -71,6 +71,18 @@ namespace build2 bool force = false, fdstream_mode mode = fdstream_mode::skip); + // Check whether the buffer has been opened with the open() call and + // hasn't yet been closed. + // + // Note that this function returning true does not mean that the pipe was + // opened (to check that, call is_open() on the `is` member below). + // + bool + is_open () const + { + return state_ != state::closed; + } + // Read the diagnostics from the parent end of the pipe if one was opened // and buffer/stream it as necessary. Return true if there could be more // diagnostics to read (only possible in the non-blocking mode). -- cgit v1.1