[llvm-commits] CVS: llvm/lib/Bytecode/Archive/ArchiveWriter.cpp

Jeff Cohen jeffc at jolt-lang.org
Sat Jan 22 09:36:31 PST 2005



Changes in directory llvm/lib/Bytecode/Archive:

ArchiveWriter.cpp updated: 1.13 -> 1.14
---
Log message:

Use binary mode for reading/writing bytecode files

---
Diffs of the changes:  (+4 -2)

 ArchiveWriter.cpp |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)


Index: llvm/lib/Bytecode/Archive/ArchiveWriter.cpp
diff -u llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.13 llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.14
--- llvm/lib/Bytecode/Archive/ArchiveWriter.cpp:1.13	Sun Dec 19 21:23:46 2004
+++ llvm/lib/Bytecode/Archive/ArchiveWriter.cpp	Sat Jan 22 11:36:16 2005
@@ -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();
       }






More information about the llvm-commits mailing list