summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Archive/Archive.cpp8
-rw-r--r--lib/Archive/ArchiveWriter.cpp17
-rw-r--r--lib/Bytecode/Archive/Archive.cpp8
-rw-r--r--lib/Bytecode/Archive/ArchiveWriter.cpp17
4 files changed, 38 insertions, 12 deletions
diff --git a/lib/Archive/Archive.cpp b/lib/Archive/Archive.cpp
index 3bb9a055083..d5b56ca85e2 100644
--- a/lib/Archive/Archive.cpp
+++ b/lib/Archive/Archive.cpp
@@ -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;
}
}
diff --git a/lib/Archive/ArchiveWriter.cpp b/lib/Archive/ArchiveWriter.cpp
index dc7ef672055..a5b52f465a9 100644
--- a/lib/Archive/ArchiveWriter.cpp
+++ b/lib/Archive/ArchiveWriter.cpp
@@ -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
diff --git a/lib/Bytecode/Archive/Archive.cpp b/lib/Bytecode/Archive/Archive.cpp
index 3bb9a055083..d5b56ca85e2 100644
--- a/lib/Bytecode/Archive/Archive.cpp
+++ b/lib/Bytecode/Archive/Archive.cpp
@@ -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;
}
}
diff --git a/lib/Bytecode/Archive/ArchiveWriter.cpp b/lib/Bytecode/Archive/ArchiveWriter.cpp
index dc7ef672055..a5b52f465a9 100644
--- a/lib/Bytecode/Archive/ArchiveWriter.cpp
+++ b/lib/Bytecode/Archive/ArchiveWriter.cpp
@@ -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