diff options
author | Jeff Cohen <jeffc@jolt-lang.org> | 2005-01-22 17:36:17 +0000 |
---|---|---|
committer | Jeff Cohen <jeffc@jolt-lang.org> | 2005-01-22 17:36:17 +0000 |
commit | 5fb6ed4ae608c6f7ef589f1069b5dd5c7bdbd60b (patch) | |
tree | 1a699df0388afa1ed3d3acc4e4cd91085adbed10 /lib | |
parent | 695c9bdbd0ad9d540dea68e201cd616afb4320d4 (diff) |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Archive/ArchiveWriter.cpp | 6 | ||||
-rw-r--r-- | lib/Bytecode/Archive/ArchiveWriter.cpp | 6 | ||||
-rw-r--r-- | lib/Support/FileUtilities.cpp | 5 | ||||
-rw-r--r-- | lib/VMCore/Verifier.cpp | 8 |
4 files changed, 15 insertions, 10 deletions
diff --git a/lib/Archive/ArchiveWriter.cpp b/lib/Archive/ArchiveWriter.cpp index 5c7b126320..f16376725d 100644 --- a/lib/Archive/ArchiveWriter.cpp +++ b/lib/Archive/ArchiveWriter.cpp @@ -375,7 +375,9 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress){ // 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 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress){ 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(); } diff --git a/lib/Bytecode/Archive/ArchiveWriter.cpp b/lib/Bytecode/Archive/ArchiveWriter.cpp index 5c7b126320..f16376725d 100644 --- a/lib/Bytecode/Archive/ArchiveWriter.cpp +++ b/lib/Bytecode/Archive/ArchiveWriter.cpp @@ -375,7 +375,9 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress){ // 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 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress){ 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(); } diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp index 5255df64e5..234cf7d260 100644 --- a/lib/Support/FileUtilities.cpp +++ b/lib/Support/FileUtilities.cpp @@ -27,13 +27,14 @@ using namespace llvm; /// bool llvm::DiffFiles(const std::string &FileA, const std::string &FileB, std::string *Error) { - std::ifstream FileAStream(FileA.c_str()); + std::ios::openmode io_mode = std::ios::in | std::ios::binary; + std::ifstream FileAStream(FileA.c_str(), io_mode); if (!FileAStream) { if (Error) *Error = "Couldn't open file '" + FileA + "'"; return true; } - std::ifstream FileBStream(FileB.c_str()); + std::ifstream FileBStream(FileB.c_str(), io_mode); if (!FileBStream) { if (Error) *Error = "Couldn't open file '" + FileB + "'"; return true; diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 0998720a4a..ad1074d8d3 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -78,17 +78,17 @@ namespace { // Anonymous namespace for class Verifier() : Broken(false), RealPass(true), action(AbortProcessAction), - DS(0), msgs( std::ios_base::app | std::ios_base::out ) {} + DS(0), msgs( std::ios::app | std::ios::out ) {} Verifier( VerifierFailureAction ctn ) : Broken(false), RealPass(true), action(ctn), DS(0), - msgs( std::ios_base::app | std::ios_base::out ) {} + msgs( std::ios::app | std::ios::out ) {} Verifier(bool AB ) : Broken(false), RealPass(true), action( AB ? AbortProcessAction : PrintMessageAction), DS(0), - msgs( std::ios_base::app | std::ios_base::out ) {} + msgs( std::ios::app | std::ios::out ) {} Verifier(DominatorSet &ds) : Broken(false), RealPass(false), action(PrintMessageAction), - DS(&ds), msgs( std::ios_base::app | std::ios_base::out ) {} + DS(&ds), msgs( std::ios::app | std::ios::out ) {} bool doInitialization(Module &M) { |