Use binary mode for reading/writing bytecode files


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19751 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Bytecode/Archive/ArchiveWriter.cpp b/lib/Bytecode/Archive/ArchiveWriter.cpp
index 5c7b126..f163767 100644
--- a/lib/Bytecode/Archive/ArchiveWriter.cpp
+++ b/lib/Bytecode/Archive/ArchiveWriter.cpp
@@ -375,7 +375,9 @@
   // Ensure we can remove the temporary even in the face of an exception
   try {
     // Create archive file for output.
-    std::ofstream ArchiveFile(TmpArchive.c_str());
+    std::ios::openmode io_mode = std::ios::out | std::ios::trunc |
+                                 std::ios::binary;
+    std::ofstream ArchiveFile(TmpArchive.c_str(), io_mode);
   
     // Check for errors opening or creating archive file.
     if ( !ArchiveFile.is_open() || ArchiveFile.bad() ) {
@@ -413,7 +415,7 @@
       const char* base = (const char*) arch.map();
 
       // Open the final file to write and check it.
-      std::ofstream FinalFile(archPath.c_str());
+      std::ofstream FinalFile(archPath.c_str(), io_mode);
       if ( !FinalFile.is_open() || FinalFile.bad() ) {
         throw std::string("Error opening archive file: ") + archPath.toString();
       }