From 9d39cb1d6418c5a25fa74f09e593794a4c8fd4b6 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 20 Jun 2013 13:23:48 +0000 Subject: Revert "Don't include directory names in archives." This reverts commit 184420. Investigating the bot failures. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184421 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-ar/ArchiveWriter.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'tools/llvm-ar/ArchiveWriter.cpp') diff --git a/tools/llvm-ar/ArchiveWriter.cpp b/tools/llvm-ar/ArchiveWriter.cpp index 332d55f0a4..5563b564b3 100644 --- a/tools/llvm-ar/ArchiveWriter.cpp +++ b/tools/llvm-ar/ArchiveWriter.cpp @@ -98,7 +98,13 @@ Archive::fillHeader(const ArchiveMember &mbr, ArchiveMemberHeader& hdr, sprintf(buffer,"%-12u", unsigned(secondsSinceEpoch)); memcpy(hdr.date,buffer,12); - std::string mbrPath = sys::path::filename(mbr.getPath()); + // Get rid of trailing blanks in the name + std::string mbrPath = mbr.getPath().str(); + size_t mbrLen = mbrPath.length(); + while (mbrLen > 0 && mbrPath[mbrLen-1] == ' ') { + mbrPath.erase(mbrLen-1,1); + mbrLen--; + } // Set the name field in one of its various flavors. bool writeLongName = false; @@ -159,8 +165,8 @@ bool Archive::addFileBefore(StringRef filePath, iterator where, ArchiveMember* mbr = new ArchiveMember(this); mbr->data = 0; - mbr->path = filePath; - sys::PathWithStatus PWS(filePath); + mbr->path = filePath.str(); + sys::PathWithStatus PWS(mbr->path); const sys::FileStatus *FSInfo = PWS.getFileStatus(false, ErrMsg); if (!FSInfo) { delete mbr; @@ -173,7 +179,10 @@ bool Archive::addFileBefore(StringRef filePath, iterator where, mbr->Size = FSInfo->getSize(); unsigned flags = 0; - if (sys::path::filename(filePath).size() > 15) + bool hasSlash = filePath.str().find('/') != std::string::npos; + if (hasSlash) + flags |= ArchiveMember::HasPathFlag; + if (hasSlash || filePath.str().length() > 15) flags |= ArchiveMember::HasLongFilenameFlag; sys::fs::file_magic type; -- cgit v1.2.3