mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-24 09:29:42 +00:00
Add a helper function to reduce a bit of code duplication.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241691 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e933e5bd08
commit
9ff2cd5417
@ -124,6 +124,18 @@ static void printMemberHeader(raw_fd_ostream &Out, unsigned NameOffset,
|
|||||||
printRestOfMemberHeader(Out, ModTime, UID, GID, Perms, Size);
|
printRestOfMemberHeader(Out, ModTime, UID, GID, Perms, Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
printMemberHeader(raw_fd_ostream &Out, StringRef Name,
|
||||||
|
std::vector<unsigned>::iterator &StringMapIndexIter,
|
||||||
|
const sys::TimeValue &ModTime, unsigned UID, unsigned GID,
|
||||||
|
unsigned Perms, unsigned Size) {
|
||||||
|
if (Name.size() < 16)
|
||||||
|
printMemberHeader(Out, Name, ModTime, UID, GID, Perms, Size);
|
||||||
|
else
|
||||||
|
printMemberHeader(Out, *StringMapIndexIter++, ModTime, UID, GID, Perms,
|
||||||
|
Size);
|
||||||
|
}
|
||||||
|
|
||||||
static void writeStringTable(raw_fd_ostream &Out,
|
static void writeStringTable(raw_fd_ostream &Out,
|
||||||
ArrayRef<NewArchiveIterator> Members,
|
ArrayRef<NewArchiveIterator> Members,
|
||||||
std::vector<unsigned> &StringMapIndexes) {
|
std::vector<unsigned> &StringMapIndexes) {
|
||||||
@ -278,8 +290,8 @@ llvm::writeArchive(StringRef ArcName,
|
|||||||
writeStringTable(Out, NewMembers, StringMapIndexes);
|
writeStringTable(Out, NewMembers, StringMapIndexes);
|
||||||
|
|
||||||
unsigned MemberNum = 0;
|
unsigned MemberNum = 0;
|
||||||
unsigned LongNameMemberNum = 0;
|
|
||||||
unsigned NewMemberNum = 0;
|
unsigned NewMemberNum = 0;
|
||||||
|
std::vector<unsigned>::iterator StringMapIndexIter = StringMapIndexes.begin();
|
||||||
std::vector<unsigned> MemberOffset;
|
std::vector<unsigned> MemberOffset;
|
||||||
for (const NewArchiveIterator &I : NewMembers) {
|
for (const NewArchiveIterator &I : NewMembers) {
|
||||||
MemoryBufferRef File = Members[MemberNum++];
|
MemoryBufferRef File = Members[MemberNum++];
|
||||||
@ -289,32 +301,17 @@ llvm::writeArchive(StringRef ArcName,
|
|||||||
|
|
||||||
if (I.isNewMember()) {
|
if (I.isNewMember()) {
|
||||||
StringRef FileName = I.getNew();
|
StringRef FileName = I.getNew();
|
||||||
const sys::fs::file_status &Status = NewMemberStatus[NewMemberNum];
|
const sys::fs::file_status &Status = NewMemberStatus[NewMemberNum++];
|
||||||
NewMemberNum++;
|
printMemberHeader(Out, sys::path::filename(FileName), StringMapIndexIter,
|
||||||
|
Status.getLastModificationTime(), Status.getUser(),
|
||||||
StringRef Name = sys::path::filename(FileName);
|
Status.getGroup(), Status.permissions(),
|
||||||
if (Name.size() < 16)
|
Status.getSize());
|
||||||
printMemberHeader(Out, Name, Status.getLastModificationTime(),
|
|
||||||
Status.getUser(), Status.getGroup(),
|
|
||||||
Status.permissions(), Status.getSize());
|
|
||||||
else
|
|
||||||
printMemberHeader(Out, StringMapIndexes[LongNameMemberNum++],
|
|
||||||
Status.getLastModificationTime(), Status.getUser(),
|
|
||||||
Status.getGroup(), Status.permissions(),
|
|
||||||
Status.getSize());
|
|
||||||
} else {
|
} else {
|
||||||
object::Archive::child_iterator OldMember = I.getOld();
|
object::Archive::child_iterator OldMember = I.getOld();
|
||||||
StringRef Name = I.getName();
|
printMemberHeader(Out, I.getName(), StringMapIndexIter,
|
||||||
|
OldMember->getLastModified(), OldMember->getUID(),
|
||||||
if (Name.size() < 16)
|
OldMember->getGID(), OldMember->getAccessMode(),
|
||||||
printMemberHeader(Out, Name, OldMember->getLastModified(),
|
OldMember->getSize());
|
||||||
OldMember->getUID(), OldMember->getGID(),
|
|
||||||
OldMember->getAccessMode(), OldMember->getSize());
|
|
||||||
else
|
|
||||||
printMemberHeader(Out, StringMapIndexes[LongNameMemberNum++],
|
|
||||||
OldMember->getLastModified(), OldMember->getUID(),
|
|
||||||
OldMember->getGID(), OldMember->getAccessMode(),
|
|
||||||
OldMember->getSize());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Out << File.getBuffer();
|
Out << File.getBuffer();
|
||||||
|
Loading…
Reference in New Issue
Block a user