Support/Path: Deprecate Path::hasMagicNumber and replace all uses with fs::has_magic.
authorMichael J. Spencer <bigcheesegs@gmail.com>
Tue, 28 Dec 2010 01:49:21 +0000 (01:49 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Tue, 28 Dec 2010 01:49:21 +0000 (01:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122589 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/PathV1.h
lib/Support/Path.cpp

index 1fec1e56c834e40e5efeecf27fe72e7dba54676e..86fdb0c0accb7c6488ce95af6f0ba4f76c46c8d3 100644 (file)
@@ -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
index c3353fd0e2b212fd0825758a9b41b0bebcb7db08..3e0ee8dd86d07abd9d3ec6171d5e47b3ba9f8d4b 100644 (file)
@@ -140,7 +140,11 @@ sys::IdentifyFileType(const char *magic, unsigned length) {
 
 bool
 Path::isArchive() const {
-  return hasMagicNumber("!<arch>\012");
+  std::string Magic;
+  if (getMagicNumber(Magic, 8))
+    if (IdentifyFileType(Magic.c_str(), Magic.length()) == Archive_FileType)
+      return true;
+  return false;
 }
 
 bool