X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Fllvm-ar%2FArchiveWriter.cpp;h=bdccf3e0d91d1ecfef0c75feb7b2a5ac00da98d9;hb=11eb51e23935e22e1cb7b346c45713e8c9169c84;hp=8f010ad7ba8dcb6f001a3233aacda3b8376cc988;hpb=19ead5a9f1c758641fb148f9c5fb64e381f90ad3;p=oota-llvm.git diff --git a/tools/llvm-ar/ArchiveWriter.cpp b/tools/llvm-ar/ArchiveWriter.cpp index 8f010ad7ba8..bdccf3e0d91 100644 --- a/tools/llvm-ar/ArchiveWriter.cpp +++ b/tools/llvm-ar/ArchiveWriter.cpp @@ -80,7 +80,7 @@ Archive* Archive::CreateEmpty(StringRef FilePath, LLVMContext& C) { // compressed. bool Archive::fillHeader(const ArchiveMember &mbr, ArchiveMemberHeader& hdr, - int sz, bool TruncateNames) const { + int sz) const { // Set the permissions mode, uid and gid hdr.init(); @@ -107,18 +107,6 @@ Archive::fillHeader(const ArchiveMember &mbr, ArchiveMemberHeader& hdr, memcpy(hdr.name,ARFILE_SVR4_SYMTAB_NAME,16); } else if (mbr.isBSD4SymbolTable()) { memcpy(hdr.name,ARFILE_BSD4_SYMTAB_NAME,16); - } else if (TruncateNames) { - const char* nm = mbrPath.c_str(); - unsigned len = mbrPath.length(); - size_t slashpos = mbrPath.rfind('/'); - if (slashpos != std::string::npos) { - nm += slashpos + 1; - len -= slashpos +1; - } - if (len > 15) - len = 15; - memcpy(hdr.name,nm,len); - hdr.name[len] = '/'; } else if (mbrPath.length() < 16 && mbrPath.find('/') == std::string::npos) { memcpy(hdr.name,mbrPath.c_str(),mbrPath.length()); hdr.name[mbrPath.length()] = '/'; @@ -183,13 +171,6 @@ bool Archive::addFileBefore(StringRef filePath, iterator where, sys::fs::file_magic type; if (sys::fs::identify_magic(mbr->path, type)) type = sys::fs::file_magic::unknown; - switch (type) { - case sys::fs::file_magic::bitcode: - flags |= ArchiveMember::BitcodeFlag; - break; - default: - break; - } mbr->flags = flags; members.insert(where,mbr); return false; @@ -200,7 +181,6 @@ bool Archive::writeMember( const ArchiveMember& member, raw_fd_ostream& ARFile, - bool TruncateNames, std::string* ErrMsg ) { @@ -228,7 +208,7 @@ Archive::writeMember( // Compute the fields of the header ArchiveMemberHeader Hdr; - bool writeLongName = fillHeader(member,Hdr,hdrSize,TruncateNames); + bool writeLongName = fillHeader(member,Hdr,hdrSize); // Write header to archive file ARFile.write((char*)&Hdr, sizeof(Hdr)); @@ -255,7 +235,7 @@ Archive::writeMember( // This writes to a temporary file first. Options are for creating a symbol // table, flattening the file names (no directories, 15 chars max) and // compressing each archive member. -bool Archive::writeToDisk(bool TruncateNames, std::string *ErrMsg) { +bool Archive::writeToDisk(std::string *ErrMsg) { // Make sure they haven't opened up the file, not loaded it, // but are now trying to write it which would wipe out the file. if (members.empty() && mapfile && mapfile->getBufferSize() > 8) { @@ -267,8 +247,8 @@ bool Archive::writeToDisk(bool TruncateNames, std::string *ErrMsg) { // Create a temporary file to store the archive in int TmpArchiveFD; SmallString<128> TmpArchive; - error_code EC = sys::fs::unique_file("temp-archive-%%%%%%%.a", TmpArchiveFD, - TmpArchive, true, 0666); + error_code EC = sys::fs::createUniqueFile( + archPath + ".temp-archive-%%%%%%%.a", TmpArchiveFD, TmpArchive); if (EC) return true; @@ -284,7 +264,7 @@ bool Archive::writeToDisk(bool TruncateNames, std::string *ErrMsg) { // Loop over all member files, and write them out. Note that this also // builds the symbol table, symTab. for (MembersList::iterator I = begin(), E = end(); I != E; ++I) { - if (writeMember(*I, ArchiveFile, TruncateNames, ErrMsg)) { + if (writeMember(*I, ArchiveFile, ErrMsg)) { sys::fs::remove(Twine(TmpArchive)); ArchiveFile.close(); return true;