[llvm-commits] [llvm] r122589 - in /llvm/trunk: include/llvm/Support/PathV1.h lib/Support/Path.cpp

Michael J. Spencer bigcheesegs at gmail.com
Mon Dec 27 17:49:21 PST 2010


Author: mspencer
Date: Mon Dec 27 19:49:21 2010
New Revision: 122589

URL: http://llvm.org/viewvc/llvm-project?rev=122589&view=rev
Log:
Support/Path: Deprecate Path::hasMagicNumber and replace all uses with fs::has_magic.

Modified:
    llvm/trunk/include/llvm/Support/PathV1.h
    llvm/trunk/lib/Support/Path.cpp

Modified: llvm/trunk/include/llvm/Support/PathV1.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/PathV1.h?rev=122589&r1=122588&r2=122589&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/PathV1.h (original)
+++ llvm/trunk/include/llvm/Support/PathV1.h Mon Dec 27 19:49:21 2010
@@ -329,7 +329,8 @@
       /// 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

Modified: llvm/trunk/lib/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=122589&r1=122588&r2=122589&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Path.cpp (original)
+++ llvm/trunk/lib/Support/Path.cpp Mon Dec 27 19:49:21 2010
@@ -140,7 +140,11 @@
 
 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





More information about the llvm-commits mailing list