summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-07-15 17:29:42 +0000
committerDan Gohman <gohman@apple.com>2009-07-15 17:29:42 +0000
commit607818a2c17267f5c49745fe987ec6a43145b059 (patch)
treec6924b900aaddd14027ca45a60bd73d57f887c18 /llvm/lib/Support
parent338191cd67a0a3e324c8b1475c975fed5ffa9e94 (diff)
downloadbcm5719-llvm-607818a2c17267f5c49745fe987ec6a43145b059.tar.gz
bcm5719-llvm-607818a2c17267f5c49745fe987ec6a43145b059.zip
Add a Force option to raw_fd_ostream to specify whether opening
an existing file is considered an error. Convert several tools to use raw_fd_ostream instead of std::ostream, and to use this new option instead of doing a manual check. llvm-svn: 75801
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r--llvm/lib/Support/raw_ostream.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index 0595fe47e12..b13d922b217 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -246,7 +246,7 @@ 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, bool Binary,
+raw_fd_ostream::raw_fd_ostream(const char *Filename, bool Binary, bool Force,
std::string &ErrorInfo) : pos(0) {
ErrorInfo.clear();
@@ -266,6 +266,8 @@ raw_fd_ostream::raw_fd_ostream(const char *Filename, bool Binary,
if (Binary)
Flags |= O_BINARY;
#endif
+ if (!Force)
+ Flags |= O_EXCL;
FD = open(Filename, Flags, 0664);
if (FD < 0) {
ErrorInfo = "Error opening output file '" + std::string(Filename) + "'";
OpenPOWER on IntegriCloud