summaryrefslogtreecommitdiff
path: root/tools/llvm-ar/ArchiveWriter.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-06-20 13:23:48 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-06-20 13:23:48 +0000
commit9d39cb1d6418c5a25fa74f09e593794a4c8fd4b6 (patch)
treecb9c4a3c46ec16fda8286aee56c13443f08efcad /tools/llvm-ar/ArchiveWriter.cpp
parentbe984d6376bf42f9e05fb660b44808cffe9711a8 (diff)
downloadllvm-9d39cb1d6418c5a25fa74f09e593794a4c8fd4b6.tar.gz
llvm-9d39cb1d6418c5a25fa74f09e593794a4c8fd4b6.tar.bz2
llvm-9d39cb1d6418c5a25fa74f09e593794a4c8fd4b6.tar.xz
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
Diffstat (limited to 'tools/llvm-ar/ArchiveWriter.cpp')
-rw-r--r--tools/llvm-ar/ArchiveWriter.cpp17
1 files changed, 13 insertions, 4 deletions
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;