mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-16 14:31:59 +00:00
Added raw_fd_ostream::close().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58052 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
93fbe75a94
commit
43d1f02b54
@ -168,6 +168,9 @@ public:
|
|||||||
/// subclasses. This outputs the currently buffered data and resets the
|
/// subclasses. This outputs the currently buffered data and resets the
|
||||||
/// buffer to empty.
|
/// buffer to empty.
|
||||||
virtual void flush_impl();
|
virtual void flush_impl();
|
||||||
|
|
||||||
|
/// close - Manually flush the stream and close the file.
|
||||||
|
void close();
|
||||||
};
|
};
|
||||||
|
|
||||||
/// raw_stdout_ostream - This is a stream that always prints to stdout.
|
/// raw_stdout_ostream - This is a stream that always prints to stdout.
|
||||||
|
@ -220,17 +220,28 @@ raw_fd_ostream::raw_fd_ostream(const char *Filename, std::string &ErrorInfo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
raw_fd_ostream::~raw_fd_ostream() {
|
raw_fd_ostream::~raw_fd_ostream() {
|
||||||
flush();
|
if (FD >= 0) {
|
||||||
if (ShouldClose)
|
flush();
|
||||||
close(FD);
|
if (ShouldClose)
|
||||||
|
::close(FD);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void raw_fd_ostream::flush_impl() {
|
void raw_fd_ostream::flush_impl() {
|
||||||
|
assert (FD >= 0 && "File already closed.");
|
||||||
if (OutBufCur-OutBufStart)
|
if (OutBufCur-OutBufStart)
|
||||||
::write(FD, OutBufStart, OutBufCur-OutBufStart);
|
::write(FD, OutBufStart, OutBufCur-OutBufStart);
|
||||||
HandleFlush();
|
HandleFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void raw_fd_ostream::close() {
|
||||||
|
assert (ShouldClose);
|
||||||
|
ShouldClose = false;
|
||||||
|
flush();
|
||||||
|
::close(FD);
|
||||||
|
FD = -1;
|
||||||
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// raw_stdout/err_ostream
|
// raw_stdout/err_ostream
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user