Use a raw_fd_ostream instead of a std::ofstream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184460 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp
index 53b2d02..b1b175f 100644
--- a/tools/llvm-ar/llvm-ar.cpp
+++ b/tools/llvm-ar/llvm-ar.cpp
@@ -25,7 +25,6 @@
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cstdlib>
-#include <fstream>
#include <memory>
using namespace llvm;
@@ -400,9 +399,11 @@
(std::find(Paths.begin(), Paths.end(), I->getPath()) != Paths.end())) {
// Open up a file stream for writing
- std::ios::openmode io_mode = std::ios::out | std::ios::trunc |
- std::ios::binary;
- std::ofstream file(I->getPath().str().c_str(), io_mode);
+ std::string Err;
+ raw_fd_ostream file(I->getPath().str().c_str(), Err,
+ raw_fd_ostream::F_Binary);
+ if (!Err.empty())
+ fail(Err);
// Get the data and its length
const char* data = reinterpret_cast<const char*>(I->getData());