llvm.org GIT mirror llvm / ba7661d
For new archive member we only need to store the full path. We were storing both the path and the file name, which was redundant and easy to get confused up with. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242347 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 4 years ago
4 changed file(s) with 13 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
2525
2626 object::Archive::child_iterator OldI;
2727
28 StringRef NewFilename;
29
3028 public:
3129 NewArchiveIterator(object::Archive::child_iterator I, StringRef Name);
32 NewArchiveIterator(StringRef I, StringRef Name);
30 NewArchiveIterator(StringRef FileName);
3331 bool isNewMember() const;
3432 StringRef getName() const;
3533
134134 llvm::errs() << Arg->getValue() << ": no such file or directory\n";
135135 return 1;
136136 }
137 Members.emplace_back(Saver.save(*Path),
138 llvm::sys::path::filename(Arg->getValue()));
137 Members.emplace_back(Saver.save(*Path));
139138 }
140139
141140 std::pair Result =
3737 StringRef Name)
3838 : IsNewMember(false), Name(Name), OldI(I) {}
3939
40 NewArchiveIterator::NewArchiveIterator(StringRef NewFilename, StringRef Name)
41 : IsNewMember(true), Name(Name), NewFilename(NewFilename) {}
40 NewArchiveIterator::NewArchiveIterator(StringRef FileName)
41 : IsNewMember(true), Name(FileName) {}
4242
4343 StringRef NewArchiveIterator::getName() const { return Name; }
4444
5151
5252 StringRef NewArchiveIterator::getNew() const {
5353 assert(IsNewMember);
54 return NewFilename;
54 return Name;
5555 }
5656
5757 llvm::ErrorOr
5858 NewArchiveIterator::getFD(sys::fs::file_status &NewStatus) const {
5959 assert(IsNewMember);
6060 int NewFD;
61 if (auto EC = sys::fs::openFileForRead(NewFilename, NewFD))
61 if (auto EC = sys::fs::openFileForRead(Name, NewFD))
6262 return EC;
6363 assert(NewFD != -1);
6464
436436 }
437437
438438 void addMember(std::vector &Members, StringRef FileName,
439 StringRef Name, int Pos = -1) {
440 NewArchiveIterator NI(FileName, Name);
439 int Pos = -1) {
440 NewArchiveIterator NI(FileName);
441441 if (Pos == -1)
442442 Members.push_back(NI);
443443 else
543543 addMember(Ret, Child, Name);
544544 break;
545545 case IA_AddNewMeber:
546 addMember(Ret, *MemberI, Name);
546 addMember(Ret, *MemberI);
547547 break;
548548 case IA_Delete:
549549 break;
551551 addMember(Moved, Child, Name);
552552 break;
553553 case IA_MoveNewMember:
554 addMember(Moved, *MemberI, Name);
554 addMember(Moved, *MemberI);
555555 break;
556556 }
557557 if (MemberI != Members.end())
571571 assert(unsigned(InsertPos) <= Ret.size());
572572 Ret.insert(Ret.begin() + InsertPos, Moved.begin(), Moved.end());
573573
574 Ret.insert(Ret.begin() + InsertPos, Members.size(),
575 NewArchiveIterator("", ""));
574 Ret.insert(Ret.begin() + InsertPos, Members.size(), NewArchiveIterator(""));
576575 int Pos = InsertPos;
577576 for (auto &Member : Members) {
578 StringRef Name = sys::path::filename(Member);
579 addMember(Ret, Member, Name, Pos);
577 addMember(Ret, Member, Pos);
580578 ++Pos;
581579 }
582580
735733 break;
736734 }
737735 case MRICommand::AddMod:
738 addMember(NewMembers, Rest, sys::path::filename(Rest));
736 addMember(NewMembers, Rest);
739737 break;
740738 case MRICommand::Create:
741739 Create = true;