change the archive stuff to use MemoryBuffer instead of mappedfile.
MemoryBuffer is higher level and more closely matches the model
needed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49029 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Archive/Archive.cpp b/lib/Archive/Archive.cpp
index c5da114..e32c716 100644
--- a/lib/Archive/Archive.cpp
+++ b/lib/Archive/Archive.cpp
@@ -17,7 +17,6 @@
#include "llvm/ModuleProvider.h"
#include "llvm/Module.h"
#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/System/MappedFile.h"
#include "llvm/System/Process.h"
#include <memory>
#include <cstring>
@@ -145,25 +144,19 @@
}
bool
-Archive::mapToMemory(std::string* ErrMsg)
-{
- mapfile = new sys::MappedFile();
- if (mapfile->open(archPath, ErrMsg))
+Archive::mapToMemory(std::string* ErrMsg) {
+ mapfile = MemoryBuffer::getFile(archPath.c_str(), archPath.size(), ErrMsg);
+ if (mapfile == 0)
return true;
- if (!(base = (char*) mapfile->map(ErrMsg)))
- return true;
+ base = mapfile->getBufferStart();
return false;
}
void Archive::cleanUpMemory() {
// Shutdown the file mapping
- if (mapfile) {
- mapfile->close();
- delete mapfile;
-
- mapfile = 0;
- base = 0;
- }
+ delete mapfile;
+ mapfile = 0;
+ base = 0;
// Forget the entire symbol table
symTab.clear();