System/Path: Add isObjectFile().

llvm-svn: 114032
diff --git a/llvm/lib/System/Path.cpp b/llvm/lib/System/Path.cpp
index 4445c66..0026fd2 100644
--- a/llvm/lib/System/Path.cpp
+++ b/llvm/lib/System/Path.cpp
@@ -156,6 +156,20 @@
   return false;
 }
 
+bool
+Path::isObjectFile() const {
+  std::string Magic;
+  if (getMagicNumber(Magic, 64))
+    if (IdentifyFileType(Magic.c_str(),
+                         static_cast<unsigned>(Magic.length()))
+        != Unknown_FileType) {
+      // Everything in LLVMFileType is currently an object file.
+      return true;
+    }
+
+  return false;
+}
+
 Path
 Path::FindLibrary(std::string& name) {
   std::vector<sys::Path> LibPaths;