For PR797:
authorReid Spencer <rspencer@reidspencer.com>
Tue, 22 Aug 2006 16:07:44 +0000 (16:07 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Tue, 22 Aug 2006 16:07:44 +0000 (16:07 +0000)
Adjust to new interface for MappedFile. Note that the new "throw"
statements will be removed later.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29818 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Archive/Archive.cpp
lib/Archive/ArchiveWriter.cpp
lib/Bytecode/Archive/Archive.cpp
lib/Bytecode/Archive/ArchiveWriter.cpp

index 3bb9a05508384e9478e9a163f9eb67aadcabf791..d5b56ca85e292e255581fd91e2c0f4813b753160 100644 (file)
@@ -137,8 +137,12 @@ Archive::Archive(const sys::Path& filename, bool map )
     symTabSize(0), firstFileOffset(0), modules(), foreignST(0)
 {
   if (map) {
-    mapfile = new sys::MappedFile(filename);
-    base = (char*) mapfile->map();
+    std::string ErrMsg;
+    mapfile = new sys::MappedFile();
+    if (mapfile->open(filename, sys::MappedFile::READ_ACCESS, &ErrMsg))
+      throw ErrMsg;
+    if (!(base = (char*) mapfile->map(&ErrMsg)))
+      throw ErrMsg;
   }
 }
 
index dc7ef672055138bf1dbd9e93c59b6cff584a980d..a5b52f465a9792f64a97145dda9aad0d19963800 100644 (file)
@@ -205,8 +205,12 @@ Archive::writeMember(
   const char* data = (const char*)member.getData();
   sys::MappedFile* mFile = 0;
   if (!data) {
-    mFile = new sys::MappedFile(member.getPath());
-    data = (const char*) mFile->map();
+    std::string ErrMsg;
+    mFile = new sys::MappedFile();
+    if (mFile->open(member.getPath(), sys::MappedFile::READ_ACCESS, &ErrMsg))
+      throw ErrMsg;
+    if (data = (const char*) mFile->map(&ErrMsg))
+      throw ErrMsg;
     fSize = mFile->size();
   }
 
@@ -437,8 +441,13 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress,
     // we just wrote back in and copying it to the destination file.
 
     // Map in the archive we just wrote.
-    sys::MappedFile arch(TmpArchive);
-    const char* base = (const char*) arch.map();
+    sys::MappedFile arch;
+    std::string ErrMsg;
+    if (arch.open(TmpArchive, sys::MappedFile::READ_ACCESS, &ErrMsg))
+      throw ErrMsg;
+    const char* base;
+    if (!(base = (const char*) arch.map(&ErrMsg)))
+      throw ErrMsg;
 
     // Open another temporary file in order to avoid invalidating the 
     // mmapped data
index 3bb9a05508384e9478e9a163f9eb67aadcabf791..d5b56ca85e292e255581fd91e2c0f4813b753160 100644 (file)
@@ -137,8 +137,12 @@ Archive::Archive(const sys::Path& filename, bool map )
     symTabSize(0), firstFileOffset(0), modules(), foreignST(0)
 {
   if (map) {
-    mapfile = new sys::MappedFile(filename);
-    base = (char*) mapfile->map();
+    std::string ErrMsg;
+    mapfile = new sys::MappedFile();
+    if (mapfile->open(filename, sys::MappedFile::READ_ACCESS, &ErrMsg))
+      throw ErrMsg;
+    if (!(base = (char*) mapfile->map(&ErrMsg)))
+      throw ErrMsg;
   }
 }
 
index dc7ef672055138bf1dbd9e93c59b6cff584a980d..a5b52f465a9792f64a97145dda9aad0d19963800 100644 (file)
@@ -205,8 +205,12 @@ Archive::writeMember(
   const char* data = (const char*)member.getData();
   sys::MappedFile* mFile = 0;
   if (!data) {
-    mFile = new sys::MappedFile(member.getPath());
-    data = (const char*) mFile->map();
+    std::string ErrMsg;
+    mFile = new sys::MappedFile();
+    if (mFile->open(member.getPath(), sys::MappedFile::READ_ACCESS, &ErrMsg))
+      throw ErrMsg;
+    if (data = (const char*) mFile->map(&ErrMsg))
+      throw ErrMsg;
     fSize = mFile->size();
   }
 
@@ -437,8 +441,13 @@ Archive::writeToDisk(bool CreateSymbolTable, bool TruncateNames, bool Compress,
     // we just wrote back in and copying it to the destination file.
 
     // Map in the archive we just wrote.
-    sys::MappedFile arch(TmpArchive);
-    const char* base = (const char*) arch.map();
+    sys::MappedFile arch;
+    std::string ErrMsg;
+    if (arch.open(TmpArchive, sys::MappedFile::READ_ACCESS, &ErrMsg))
+      throw ErrMsg;
+    const char* base;
+    if (!(base = (const char*) arch.map(&ErrMsg)))
+      throw ErrMsg;
 
     // Open another temporary file in order to avoid invalidating the 
     // mmapped data