[llvm] r184460 - Use a raw_fd_ostream instead of a std::ofstream.
Rafael Espindola
rafael.espindola at gmail.com
Thu Jun 20 12:50:39 PDT 2013
Author: rafael
Date: Thu Jun 20 14:50:39 2013
New Revision: 184460
URL: http://llvm.org/viewvc/llvm-project?rev=184460&view=rev
Log:
Use a raw_fd_ostream instead of a std::ofstream.
Modified:
llvm/trunk/tools/llvm-ar/llvm-ar.cpp
Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=184460&r1=184459&r2=184460&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Thu Jun 20 14:50:39 2013
@@ -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 @@ doExtract(std::string* ErrMsg) {
(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());
More information about the llvm-commits
mailing list