UnRevert "Revert the archive part of "Support/PathV2: Add identify_magic.""
authorMichael J. Spencer <bigcheesegs@gmail.com>
Sun, 16 Jan 2011 21:13:51 +0000 (21:13 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Sun, 16 Jan 2011 21:13:51 +0000 (21:13 +0000)
This reverts commit dd103021a889a986a181ce36ed7b0e8dc9b645e1.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123595 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Archive/Archive.cpp
lib/Archive/ArchiveWriter.cpp

index 3ee3cb25c5a059e5eccbf3f9129f1cdd2c1de74c..1eab27d3eba3a59d36e527f27ce6d361992bcf8c 100644 (file)
@@ -116,11 +116,10 @@ bool ArchiveMember::replaceWith(const sys::Path& newFile, std::string* ErrMsg) {
 
   // Get the signature and status info
   const char* signature = (const char*) data;
-  std::string magic;
+  SmallString<4> magic;
   if (!signature) {
-    path.getMagicNumber(magic,4);
+    sys::fs::get_magic(path.str(), magic.capacity(), magic);
     signature = magic.c_str();
-    std::string err;
     const sys::FileStatus *FSinfo = path.getFileStatus(false, ErrMsg);
     if (FSinfo)
       info = *FSinfo;
index 07a9aaf4fdbe174e12ea03ea5d783884bd77d4a7..8fcc7aa29cc853ddbe9655088e56a20f24004626 100644 (file)
@@ -181,9 +181,11 @@ Archive::addFileBefore(const sys::Path& filePath, iterator where,
     flags |= ArchiveMember::HasPathFlag;
   if (hasSlash || filePath.str().length() > 15)
     flags |= ArchiveMember::HasLongFilenameFlag;
-  std::string magic;
-  mbr->path.getMagicNumber(magic,4);
-  switch (sys::IdentifyFileType(magic.c_str(),4)) {
+
+  sys::LLVMFileType type;
+  if (sys::fs::identify_magic(mbr->path.str(), type))
+    type = sys::Unknown_FileType;
+  switch (type) {
     case sys::Bitcode_FileType:
       flags |= ArchiveMember::BitcodeFlag;
       break;