From c581fe7e81958609bdacc271a6845d7e65162c05 Mon Sep 17 00:00:00 2001 From: "Michael J. Spencer" Date: Tue, 28 Dec 2010 01:49:21 +0000 Subject: [PATCH] Support/Path: Deprecate Path::hasMagicNumber and replace all uses with fs::has_magic. llvm-svn: 122589 --- llvm/include/llvm/Support/PathV1.h | 3 ++- llvm/lib/Support/Path.cpp | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/Support/PathV1.h b/llvm/include/llvm/Support/PathV1.h index 1fec1e56c834..86fdb0c0accb 100644 --- a/llvm/include/llvm/Support/PathV1.h +++ b/llvm/include/llvm/Support/PathV1.h @@ -329,7 +329,8 @@ namespace sys { /// cases (file not found, file not accessible, etc.) it returns false. /// @returns true if the magic number of the file matches \p magic. /// @brief Determine if file has a specific magic number - bool hasMagicNumber(StringRef magic) const; + LLVM_ATTRIBUTE_DEPRECATED(bool hasMagicNumber(StringRef magic) const, + LLVM_PATH_DEPRECATED_MSG(fs::has_magic)); /// This function retrieves the first \p len bytes of the file associated /// with \p this. These bytes are returned as the "magic number" in the diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index c3353fd0e2b2..3e0ee8dd86d0 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/lib/Support/Path.cpp @@ -140,7 +140,11 @@ sys::IdentifyFileType(const char *magic, unsigned length) { bool Path::isArchive() const { - return hasMagicNumber("!\012"); + std::string Magic; + if (getMagicNumber(Magic, 8)) + if (IdentifyFileType(Magic.c_str(), Magic.length()) == Archive_FileType) + return true; + return false; } bool