1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-21 03:53:04 +02:00

TarWriter: Use fitsInUstar function.

This change should have been commit as part of r291340.

llvm-svn: 291341
This commit is contained in:
Rui Ueyama 2017-01-07 08:32:07 +00:00
parent 4b6763fe74
commit a5652428f7

View File

@ -123,7 +123,7 @@ static std::pair<StringRef, StringRef> splitPath(StringRef Path) {
// Returns true if a given path can be stored to a Ustar header
// without the PAX extension.
static bool fitInUstar(StringRef Path) {
static bool fitsInUstar(StringRef Path) {
StringRef Prefix;
StringRef Name;
std::tie(Prefix, Name) = splitPath(Path);
@ -172,7 +172,7 @@ TarWriter::TarWriter(int FD, StringRef BaseDir)
void TarWriter::append(StringRef Path, StringRef Data) {
// Write Path and Data.
std::string S = BaseDir + "/" + canonicalize(Path) + "\0";
if (S.size() <= sizeof(UstarHeader::Name)) {
if (fitsInUstar(S)) {
writeUstarHeader(OS, S, Data.size());
} else {
writePaxHeader(OS, S);