diff options
author | Chris Lattner <sabre@nondot.org> | 2007-05-06 05:32:21 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-05-06 05:32:21 +0000 |
commit | 4a4499b69e08ef0ee60722abd0a1e312886a69bd (patch) | |
tree | e7bbd387a9b8234fcf96f1af9ad86f03d7e32de5 /llvm/lib/System/Path.cpp | |
parent | 963a255853d3483a72a7e5fac8757082cad2ce88 (diff) | |
download | bcm5719-llvm-4a4499b69e08ef0ee60722abd0a1e312886a69bd.tar.gz bcm5719-llvm-4a4499b69e08ef0ee60722abd0a1e312886a69bd.zip |
pull some win32 code into common code, add bitcode identification support.
llvm-svn: 36846
Diffstat (limited to 'llvm/lib/System/Path.cpp')
-rw-r--r-- | llvm/lib/System/Path.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/llvm/lib/System/Path.cpp b/llvm/lib/System/Path.cpp index 634ce5dabb0..fcdc5ff22cf 100644 --- a/llvm/lib/System/Path.cpp +++ b/llvm/lib/System/Path.cpp @@ -43,6 +43,10 @@ sys::IdentifyFileType(const char*magic, unsigned length) { assert(magic && "Invalid magic number string"); assert(length >=4 && "Invalid magic number length"); switch (magic[0]) { + case 'B': + if (magic[1] == 'C' && magic[2] == (char)0xC0 && magic[3] == (char)0xDE) + return Bitcode_FileType; + break; case 'l': if (magic[1] == 'l' && magic[2] == 'v') { if (magic[3] == 'c') @@ -160,6 +164,31 @@ std::string Path::GetDLLSuffix() { return LTDL_SHLIB_EXT; } +bool +Path::isBytecodeFile() const { + std::string actualMagic; + if (!getMagicNumber(actualMagic, 4)) + return false; + return actualMagic == "llvc" || actualMagic == "llvm"; +} + +bool +Path::isBitcodeFile() const { + std::string actualMagic; + if (!getMagicNumber(actualMagic, 4)) + return false; + return actualMagic == "BC\xC0\xDE"; +} + +bool Path::hasMagicNumber(const std::string &Magic) const { + std::string actualMagic; + if (getMagicNumber(actualMagic, Magic.size())) + return Magic == actualMagic; + return false; +} + + + // Include the truly platform-specific parts of this class. #if defined(LLVM_ON_UNIX) #include "Unix/Path.inc" |