diff options
author | Dan Gohman <gohman@apple.com> | 2010-05-27 17:12:23 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-05-27 17:12:23 +0000 |
commit | 664c1d95d193d077b4040cd7428c90decea231c1 (patch) | |
tree | f88ddf20bad8ad48ac9269ec5ea6a3d6376babc9 | |
parent | ff71bf8b828facd2dbd7c74b56cc73af6f1f035e (diff) | |
download | external_llvm-664c1d95d193d077b4040cd7428c90decea231c1.zip external_llvm-664c1d95d193d077b4040cd7428c90decea231c1.tar.gz external_llvm-664c1d95d193d077b4040cd7428c90decea231c1.tar.bz2 |
Don't bother checking canRead() before calling getMagicNumber();
getMagicNumber() does its own error checking.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104851 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/System/Path.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/lib/System/Path.cpp b/lib/System/Path.cpp index 6844530..1235257 100644 --- a/lib/System/Path.cpp +++ b/lib/System/Path.cpp @@ -136,26 +136,23 @@ sys::IdentifyFileType(const char *magic, unsigned length) { bool Path::isArchive() const { - if (canRead()) - return hasMagicNumber("!<arch>\012"); - return false; + return hasMagicNumber("!<arch>\012"); } bool Path::isDynamicLibrary() const { - if (canRead()) { - std::string Magic; - if (getMagicNumber(Magic, 64)) - switch (IdentifyFileType(Magic.c_str(), - static_cast<unsigned>(Magic.length()))) { - default: return false; - case Mach_O_FixedVirtualMemorySharedLib_FileType: - case Mach_O_DynamicallyLinkedSharedLib_FileType: - case Mach_O_DynamicallyLinkedSharedLibStub_FileType: - case ELF_SharedObject_FileType: - case COFF_FileType: return true; - } - } + std::string Magic; + if (getMagicNumber(Magic, 64)) + switch (IdentifyFileType(Magic.c_str(), + static_cast<unsigned>(Magic.length()))) { + default: return false; + case Mach_O_FixedVirtualMemorySharedLib_FileType: + case Mach_O_DynamicallyLinkedSharedLib_FileType: + case Mach_O_DynamicallyLinkedSharedLibStub_FileType: + case ELF_SharedObject_FileType: + case COFF_FileType: return true; + } + return false; } |