Changes in directory llvm/lib/System:
Path.cpp updated: 1.26 -> 1.27 --- Log message: pull some win32 code into common code, add bitcode identification support. --- Diffs of the changes: (+29 -0) Path.cpp | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+) Index: llvm/lib/System/Path.cpp diff -u llvm/lib/System/Path.cpp:1.26 llvm/lib/System/Path.cpp:1.27 --- llvm/lib/System/Path.cpp:1.26 Thu May 3 13:15:56 2007 +++ llvm/lib/System/Path.cpp Sun May 6 00:32:21 2007 @@ -43,6 +43,10 @@ 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 @@ 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" _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits