diff options
author | Daniel Dunbar <daniel@zuster.org> | 2008-11-13 05:01:07 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2008-11-13 05:01:07 +0000 |
commit | ed90e701f07158b5e042f01c6f59d27f5325c37e (patch) | |
tree | a29c0c59e49b7db8bf7565eb92cbb49d88cb18c7 /llvm/lib/Support | |
parent | 9aa657663a7ad13787674d131d759b73c6ae2dd3 (diff) | |
download | bcm5719-llvm-ed90e701f07158b5e042f01c6f59d27f5325c37e.tar.gz bcm5719-llvm-ed90e701f07158b5e042f01c6f59d27f5325c37e.zip |
Add Binary flag to raw_fd_ostream constructor.
Document raw_fd_ostream's treatment of "-".
llvm-svn: 59219
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r-- | llvm/lib/Support/raw_ostream.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp index 8c704cb4714..a8e6c782bc9 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -13,6 +13,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/Support/Format.h" +#include "llvm/System/Program.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Config/config.h" #include <ostream> @@ -200,17 +201,27 @@ void format_object_base::home() { /// occurs, information about the error is put into ErrorInfo, and the /// stream should be immediately destroyed; the string will be empty /// if no error occurred. -raw_fd_ostream::raw_fd_ostream(const char *Filename, std::string &ErrorInfo) { +raw_fd_ostream::raw_fd_ostream(const char *Filename, bool Binary, + std::string &ErrorInfo) { ErrorInfo.clear(); // Handle "-" as stdout. if (Filename[0] == '-' && Filename[1] == 0) { FD = STDOUT_FILENO; + // If user requested binary then put stdout into binary mode if + // possible. + if (Binary) + sys::Program::ChangeStdoutToBinary(); ShouldClose = false; return; } - FD = open(Filename, O_WRONLY|O_CREAT|O_TRUNC, 0644); + int Flags = O_WRONLY|O_CREAT|O_TRUNC; +#ifdef O_BINARY + if (Binary) + Flags |= O_BINARY; +#endif + FD = open(Filename, Flags, 0644); if (FD < 0) { ErrorInfo = "Error opening output file '" + std::string(Filename) + "'"; ShouldClose = false; |