From 834f0df3850c2b115e2febbf5b6bdafbe88651e2 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 11 Nov 2016 11:33:21 +0300 Subject: Add fdopen_pipe() --- butl/fdstream.ixx | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'butl/fdstream.ixx') diff --git a/butl/fdstream.ixx b/butl/fdstream.ixx index 5d38d36..e511718 100644 --- a/butl/fdstream.ixx +++ b/butl/fdstream.ixx @@ -8,6 +8,15 @@ namespace butl { // auto_fd // + inline void auto_fd:: + reset (int fd) noexcept + { + if (fd_ >= 0) + fdclose (fd_); // Don't check for an error as not much we can do here. + + fd_ = fd; + } + inline auto_fd& auto_fd:: operator= (auto_fd&& fd) noexcept { @@ -15,21 +24,10 @@ namespace butl return *this; } - inline int auto_fd:: - release () noexcept + inline auto_fd:: + ~auto_fd () noexcept { - int r (fd_); - fd_ = -1; - return r; - } - - inline void auto_fd:: - reset (int fd) noexcept - { - if (fd_ >= 0) - fdclose (fd_); // Don't check for an error as not much we can do here. - - fd_ = fd; + reset (); } // ifdstream -- cgit v1.1