diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-08-24 23:45:08 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-08-24 23:45:08 +0000 |
commit | 0ff2d31766209ce1a69d4d2c5d35761ef57362aa (patch) | |
tree | cc950d878d90c6ccb0836cf35ac004f32bc4fba1 /lib/Bytecode/Archive/Archive.cpp | |
parent | c82b3aab6502a9766ddf42b45faeca3d6fa0ad65 (diff) |
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/Bytecode/Archive/Archive.cpp')
-rw-r--r-- | lib/Bytecode/Archive/Archive.cpp | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/lib/Bytecode/Archive/Archive.cpp b/lib/Bytecode/Archive/Archive.cpp index d5b56ca85e..a661a4e992 100644 --- a/lib/Bytecode/Archive/Archive.cpp +++ b/lib/Bytecode/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() { |