aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--butl/fdstream12
-rw-r--r--butl/fdstream.cxx11
2 files changed, 11 insertions, 12 deletions
diff --git a/butl/fdstream b/butl/fdstream
index 6697dd9..cd08b13 100644
--- a/butl/fdstream
+++ b/butl/fdstream
@@ -101,8 +101,16 @@ namespace butl
fdbuf () = default;
fdbuf (auto_fd&&);
+ // Before we invented auto_fd into fdstreams we keept fdbuf opened on
+ // faulty close attempt. Now fdbuf is always closed by close() function.
+ // This semantics change seems to be the right one as there is no reason to
+ // expect fdclose() to succeed after it has already failed once.
+ //
void
- close ();
+ close () {fd_.close ();}
+
+ auto_fd
+ release () {return std::move (fd_);}
void
open (auto_fd&&);
@@ -372,6 +380,7 @@ namespace butl
open (auto_fd&& fd) {buf_.open (std::move (fd)); clear ();}
void close ();
+ auto_fd release () {return buf_.release ();} // Note: no skipping.
bool is_open () const {return buf_.is_open ();}
private:
@@ -449,6 +458,7 @@ namespace butl
open (auto_fd&& fd) {buf_.open (std::move (fd)); clear ();}
void close () {if (is_open ()) flush (); buf_.close ();}
+ auto_fd release () {if (is_open ()) flush (); return buf_.release ();}
bool is_open () const {return buf_.is_open ();}
};
diff --git a/butl/fdstream.cxx b/butl/fdstream.cxx
index d841cc2..19ef6c5 100644
--- a/butl/fdstream.cxx
+++ b/butl/fdstream.cxx
@@ -149,17 +149,6 @@ namespace butl
fd_ = move (fd);
}
- void fdbuf::
- close ()
- {
- // Before we invented auto_fd into fdstreams we keept fdbuf opened on
- // faulty close attempt. Now fdbuf is always closed by close() function.
- // This semantics change seems to be the right one as there is no reason to
- // expect fdclose() to succeed after it has already failed once.
- //
- fd_.close ();
- }
-
streamsize fdbuf::
showmanyc ()
{