diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2016-11-11 11:33:21 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2016-11-14 19:48:22 +0300 |
commit | 834f0df3850c2b115e2febbf5b6bdafbe88651e2 (patch) | |
tree | 0304a9e25585b3e59847da0ee52ddcb83464b9b1 /butl/fdstream.ixx | |
parent | b47ab3e06b8af07a79b58f23d18b5a06c2dc8108 (diff) |
Add fdopen_pipe()
Diffstat (limited to 'butl/fdstream.ixx')
-rw-r--r-- | butl/fdstream.ixx | 26 |
1 files changed, 12 insertions, 14 deletions
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 |