diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-20 13:41:51 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-20 13:41:51 +0000 |
| commit | 789c129a9fe75bf2f3bf53df636f8fdde93573b2 (patch) | |
| tree | 990e78f9cb45d08e2032ffcbc257a7211f0737ae /llvm/tools/llvm-ar/ArchiveWriter.cpp | |
| parent | 5e6b9eccce9f500069cdb957ef8100ff1b234230 (diff) | |
| download | bcm5719-llvm-789c129a9fe75bf2f3bf53df636f8fdde93573b2.tar.gz bcm5719-llvm-789c129a9fe75bf2f3bf53df636f8fdde93573b2.zip | |
Add r184420 back, but also handle long file names.
Original message:
Don't include directory names in archives.
This matches the behavior of both gnu and os x versions of ar.
llvm-svn: 184423
Diffstat (limited to 'llvm/tools/llvm-ar/ArchiveWriter.cpp')
| -rw-r--r-- | llvm/tools/llvm-ar/ArchiveWriter.cpp | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/llvm/tools/llvm-ar/ArchiveWriter.cpp b/llvm/tools/llvm-ar/ArchiveWriter.cpp index 5563b564b39..135ed5665f5 100644 --- a/llvm/tools/llvm-ar/ArchiveWriter.cpp +++ b/llvm/tools/llvm-ar/ArchiveWriter.cpp @@ -98,13 +98,7 @@ Archive::fillHeader(const ArchiveMember &mbr, ArchiveMemberHeader& hdr, sprintf(buffer,"%-12u", unsigned(secondsSinceEpoch)); memcpy(hdr.date,buffer,12); - // 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--; - } + std::string mbrPath = sys::path::filename(mbr.getPath()); // Set the name field in one of its various flavors. bool writeLongName = false; @@ -165,8 +159,8 @@ bool Archive::addFileBefore(StringRef filePath, iterator where, ArchiveMember* mbr = new ArchiveMember(this); mbr->data = 0; - mbr->path = filePath.str(); - sys::PathWithStatus PWS(mbr->path); + mbr->path = filePath; + sys::PathWithStatus PWS(filePath); const sys::FileStatus *FSInfo = PWS.getFileStatus(false, ErrMsg); if (!FSInfo) { delete mbr; @@ -179,10 +173,7 @@ bool Archive::addFileBefore(StringRef filePath, iterator where, mbr->Size = FSInfo->getSize(); unsigned flags = 0; - bool hasSlash = filePath.str().find('/') != std::string::npos; - if (hasSlash) - flags |= ArchiveMember::HasPathFlag; - if (hasSlash || filePath.str().length() > 15) + if (sys::path::filename(filePath).size() > 15) flags |= ArchiveMember::HasLongFilenameFlag; sys::fs::file_magic type; @@ -240,8 +231,8 @@ Archive::writeMember( // Write the long filename if its long if (writeLongName) { - ARFile.write(member.getPath().str().data(), - member.getPath().str().length()); + StringRef Name = sys::path::filename(member.getPath()); + ARFile.write(Name.data(), Name.size()); } // Write the (possibly compressed) member's content to the file. |

