For PR351:Remove the file type checking methods (now in sys::Path)
authorReid Spencer <rspencer@reidspencer.com>
Mon, 13 Dec 2004 02:57:41 +0000 (02:57 +0000)
committerReid Spencer <rspencer@reidspencer.com>
Mon, 13 Dec 2004 02:57:41 +0000 (02:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18846 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/FileUtilities.h
lib/Support/FileUtilities.cpp

index c9f52c324880721744ee78e42d5c62fbc9d87a1b..29d5a571eb2a1459070a99f315811938f3101578 100644 (file)
@@ -22,27 +22,27 @@ namespace llvm {
 /// CheckMagic - Returns true IFF the file named FN begins with Magic. FN must
 /// name a readable file.
 ///
-bool CheckMagic (const std::string &FN, const std::string &Magic);
+//bool CheckMagic (const std::string &FN, const std::string &Magic);
 
 /// IsArchive - Returns true IFF the file named FN appears to be a "ar" library
 /// archive. The file named FN must exist.
 ///
-bool IsArchive (const std::string &FN);
+//bool IsArchive (const std::string &FN);
 
 /// IsBytecode - Returns true IFF the file named FN appears to be an LLVM
 /// bytecode file. The file named FN must exist.
 ///
-bool IsBytecode (const std::string &FN);
+//bool IsBytecode (const std::string &FN);
 
 /// IsSharedObject - Returns trus IFF the file named FN appears to be a shared
 /// object with an ELF header. The file named FN must exist.
 ///
-bool IsSharedObject(const std::string &FN);
+//bool IsSharedObject(const std::string &FN);
 
 /// FileOpenable - Returns true IFF Filename names an existing regular file
 /// which we can successfully open.
 ///
-bool FileOpenable(const std::string &Filename);
+//bool FileOpenable(const std::string &Filename);
 
 /// DiffFiles - Compare the two files specified, returning true if they are
 /// different or if there is a file error.  If you specify a string to fill in
index 51f49772b1c4d18b51f77066ffc9db804403b5b8..5b7c56e950e2a0be2e17b5ea667bf78fa7332748 100644 (file)
 #include <iostream>
 using namespace llvm;
 
-/// CheckMagic - Returns true IFF the file named FN begins with Magic. FN must
-/// name a readable file.
-///
-bool llvm::CheckMagic(const std::string &FN, const std::string &Magic) {
-  char *buf = (char*)alloca(1 + Magic.size());
-  std::ifstream f(FN.c_str());
-  f.read(buf, Magic.size());
-  buf[Magic.size()] = '\0';
-  return Magic == buf;
-}
-
-/// IsArchive - Returns true IFF the file named FN appears to be a "ar" library
-/// archive. The file named FN must exist.
-///
-bool llvm::IsArchive(const std::string &FN) {
-  // Inspect the beginning of the file to see if it contains the "ar"
-  // library archive format magic string.
-  return CheckMagic(FN, "!<arch>\012");
-}
-
-/// IsBytecode - Returns true IFF the file named FN appears to be an LLVM
-/// bytecode file. The file named FN must exist.
-///
-bool llvm::IsBytecode(const std::string &FN) {
-  // Inspect the beginning of the file to see if it contains the LLVM
-  // bytecode format magic string.
-  return CheckMagic(FN, "llvm") || CheckMagic(FN, "llvc");
-}
-
-/// IsSharedObject - Returns trus IFF the file named FN appears to be a shared
-/// object with an ELF header. The file named FN must exist.
-///
-bool llvm::IsSharedObject(const std::string &FN) {
-  // Inspect the beginning of the file to see if it contains the ELF shared
-  // object magic string.
-  static const char elfMagic[] = { 0x7f, 'E', 'L', 'F', '\0' };
-  return CheckMagic(FN, elfMagic);
-}
-
-/// FileOpenable - Returns true IFF Filename names an existing regular
-/// file which we can successfully open.
-///
-bool llvm::FileOpenable(const std::string &Filename) {
-  struct stat s;
-  if (stat (Filename.c_str (), &s) == -1)
-    return false; // Cannot stat file
-  if (!S_ISREG (s.st_mode))
-    return false; // File is not a regular file
-  std::ifstream FileStream (Filename.c_str ());
-  if (!FileStream)
-    return false; // File is not openable
-  return true;
-}
-
 /// DiffFiles - Compare the two files specified, returning true if they are
 /// different or if there is a file error.  If you specify a string to fill in
 /// for the error option, it will set the string to an error message if an error