diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-10-23 23:49:09 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-10-23 23:49:09 +0000 |
commit | 43d1f02b547b146d81abeb0ed0f88628f0fdc7dc (patch) | |
tree | caafadc94b1122da2292212f1fce81457203c439 /lib/Support/raw_ostream.cpp | |
parent | 93fbe75a9431e49929c23847880ba61324013ee6 (diff) |
Added raw_fd_ostream::close().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58052 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/raw_ostream.cpp')
-rw-r--r-- | lib/Support/raw_ostream.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp index f3a53a5061..a4c293660b 100644 --- a/lib/Support/raw_ostream.cpp +++ b/lib/Support/raw_ostream.cpp @@ -220,17 +220,28 @@ raw_fd_ostream::raw_fd_ostream(const char *Filename, std::string &ErrorInfo) { } raw_fd_ostream::~raw_fd_ostream() { - flush(); - if (ShouldClose) - close(FD); + if (FD >= 0) { + flush(); + if (ShouldClose) + ::close(FD); + } } void raw_fd_ostream::flush_impl() { + assert (FD >= 0 && "File already closed."); if (OutBufCur-OutBufStart) ::write(FD, OutBufStart, OutBufCur-OutBufStart); HandleFlush(); } +void raw_fd_ostream::close() { + assert (ShouldClose); + ShouldClose = false; + flush(); + ::close(FD); + FD = -1; +} + //===----------------------------------------------------------------------===// // raw_stdout/err_ostream //===----------------------------------------------------------------------===// |