OSDN Git Service

TarWriter: Use fitsInUstar function.
authorRui Ueyama <ruiu@google.com>
Sat, 7 Jan 2017 08:32:07 +0000 (08:32 +0000)
committerRui Ueyama <ruiu@google.com>
Sat, 7 Jan 2017 08:32:07 +0000 (08:32 +0000)
This change should have been commit as part of r291340.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291341 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/TarWriter.cpp

index 5e45b36..57a4c8f 100644 (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);