From 96ce335f4e38fd38693f4c6cc4f745f3f4746470 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Wed, 17 Nov 2004 16:14:21 +0000 Subject: [PATCH] Adjust long file name writing to match BSD 4.4 and Mac OSX style archives. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17910 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Archive/ArchiveWriter.cpp | 24 ++++++++++++++---------- lib/Bytecode/Archive/ArchiveWriter.cpp | 24 ++++++++++++++---------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/lib/Archive/ArchiveWriter.cpp b/lib/Archive/ArchiveWriter.cpp index 636d632b664..545f4eee6eb 100644 --- a/lib/Archive/ArchiveWriter.cpp +++ b/lib/Archive/ArchiveWriter.cpp @@ -88,15 +88,6 @@ Archive::fillHeader(const ArchiveMember &mbr, ArchiveMemberHeader& hdr, sprintf(buffer, "%-6u", mbr.getGroup()); memcpy(hdr.gid,buffer,6); - // Set the size field - if (sz < 0) { - buffer[0] = '-'; - sprintf(&buffer[1],"%-9u",(unsigned)-sz); - } else { - sprintf(buffer, "%-10u", (unsigned)sz); - } - memcpy(hdr.size,buffer,10); - // Set the last modification date uint64_t secondsSinceEpoch = mbr.getModTime().toEpochTime(); sprintf(buffer,"%-12u", unsigned(secondsSinceEpoch)); @@ -130,8 +121,22 @@ Archive::fillHeader(const ArchiveMember &mbr, ArchiveMemberHeader& hdr, std::string nm = "#1/"; nm += utostr(mbrPath.length()); nm.copy(hdr.name,nm.length()); + if (sz < 0) + sz -= mbrPath.length(); + else + sz += mbrPath.length(); writeLongName = true; } + + // Set the size field + if (sz < 0) { + buffer[0] = '-'; + sprintf(&buffer[1],"%-9u",(unsigned)-sz); + } else { + sprintf(buffer, "%-10u", (unsigned)sz); + } + memcpy(hdr.size,buffer,10); + return writeLongName; } @@ -266,7 +271,6 @@ Archive::writeMember( // Write the long filename if its long if (writeLongName) { ARFile << member.getPath().c_str(); - ARFile << '\n'; } // Make sure we write the compressed bytecode magic number if we should. diff --git a/lib/Bytecode/Archive/ArchiveWriter.cpp b/lib/Bytecode/Archive/ArchiveWriter.cpp index 636d632b664..545f4eee6eb 100644 --- a/lib/Bytecode/Archive/ArchiveWriter.cpp +++ b/lib/Bytecode/Archive/ArchiveWriter.cpp @@ -88,15 +88,6 @@ Archive::fillHeader(const ArchiveMember &mbr, ArchiveMemberHeader& hdr, sprintf(buffer, "%-6u", mbr.getGroup()); memcpy(hdr.gid,buffer,6); - // Set the size field - if (sz < 0) { - buffer[0] = '-'; - sprintf(&buffer[1],"%-9u",(unsigned)-sz); - } else { - sprintf(buffer, "%-10u", (unsigned)sz); - } - memcpy(hdr.size,buffer,10); - // Set the last modification date uint64_t secondsSinceEpoch = mbr.getModTime().toEpochTime(); sprintf(buffer,"%-12u", unsigned(secondsSinceEpoch)); @@ -130,8 +121,22 @@ Archive::fillHeader(const ArchiveMember &mbr, ArchiveMemberHeader& hdr, std::string nm = "#1/"; nm += utostr(mbrPath.length()); nm.copy(hdr.name,nm.length()); + if (sz < 0) + sz -= mbrPath.length(); + else + sz += mbrPath.length(); writeLongName = true; } + + // Set the size field + if (sz < 0) { + buffer[0] = '-'; + sprintf(&buffer[1],"%-9u",(unsigned)-sz); + } else { + sprintf(buffer, "%-10u", (unsigned)sz); + } + memcpy(hdr.size,buffer,10); + return writeLongName; } @@ -266,7 +271,6 @@ Archive::writeMember( // Write the long filename if its long if (writeLongName) { ARFile << member.getPath().c_str(); - ARFile << '\n'; } // Make sure we write the compressed bytecode magic number if we should.