summaryrefslogtreecommitdiff
path: root/lib/Archive/Archive.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-08-24 23:45:08 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-08-24 23:45:08 +0000
commit0ff2d31766209ce1a69d4d2c5d35761ef57362aa (patch)
treecc950d878d90c6ccb0836cf35ac004f32bc4fba1 /lib/Archive/Archive.cpp
parentc82b3aab6502a9766ddf42b45faeca3d6fa0ad65 (diff)
downloadllvm-0ff2d31766209ce1a69d4d2c5d35761ef57362aa.tar.gz
llvm-0ff2d31766209ce1a69d4d2c5d35761ef57362aa.tar.bz2
llvm-0ff2d31766209ce1a69d4d2c5d35761ef57362aa.tar.xz
For PR797:
Remove exception handling from the bytecode archiver and adjust the llvm-ar tool to accommodate the new interfaces. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29866 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Archive/Archive.cpp')
-rw-r--r--lib/Archive/Archive.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/lib/Archive/Archive.cpp b/lib/Archive/Archive.cpp
index d5b56ca85e..a661a4e992 100644
--- a/lib/Archive/Archive.cpp
+++ b/lib/Archive/Archive.cpp
@@ -61,7 +61,7 @@ ArchiveMember::ArchiveMember(Archive* PAR)
// This method allows an ArchiveMember to be replaced with the data for a
// different file, presumably as an update to the member. It also makes sure
// the flags are reset correctly.
-void ArchiveMember::replaceWith(const sys::Path& newFile) {
+bool ArchiveMember::replaceWith(const sys::Path& newFile, std::string* ErrMsg) {
assert(newFile.exists() && "Can't replace with a non-existent file");
data = 0;
path = newFile;
@@ -110,8 +110,8 @@ void ArchiveMember::replaceWith(const sys::Path& newFile) {
path.getMagicNumber(magic,4);
signature = magic.c_str();
std::string err;
- if (path.getFileStatus(info, &err))
- throw err;
+ if (path.getFileStatus(info, ErrMsg))
+ return true;
}
// Determine what kind of file it is
@@ -127,23 +127,27 @@ void ArchiveMember::replaceWith(const sys::Path& newFile) {
flags &= ~(BytecodeFlag|CompressedBytecodeFlag);
break;
}
+ return false;
}
// Archive constructor - this is the only constructor that gets used for the
// Archive class. Everything else (default,copy) is deprecated. This just
// initializes and maps the file into memory, if requested.
-Archive::Archive(const sys::Path& filename, bool map )
+Archive::Archive(const sys::Path& filename)
: archPath(filename), members(), mapfile(0), base(0), symTab(), strtab(),
symTabSize(0), firstFileOffset(0), modules(), foreignST(0)
{
- if (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;
- }
+}
+
+bool
+Archive::mapToMemory(std::string* ErrMsg)
+{
+ mapfile = new sys::MappedFile();
+ if (mapfile->open(archPath, sys::MappedFile::READ_ACCESS, ErrMsg))
+ return true;
+ if (!(base = (char*) mapfile->map(ErrMsg)))
+ return true;
+ return false;
}
void Archive::cleanUpMemory() {