-
-
Save anonymous/57177e5f57d6859a3bea to your computer and use it in GitHub Desktop.
7zip tar pax header patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*** old/TarUpdate.cpp | |
--- new/TarUpdate.cpp | |
*************** | |
*** 13,25 **** | |
namespace NArchive { | |
namespace NTar { | |
HRESULT UpdateArchive(IInStream *inStream, ISequentialOutStream *outStream, | |
const CObjectVector<NArchive::NTar::CItemEx> &inputItems, | |
! const CObjectVector<CUpdateItem> &updateItems, | |
IArchiveUpdateCallback *updateCallback) | |
{ | |
COutArchive outArchive; | |
outArchive.Create(outStream); | |
UInt64 complexity = 0; | |
--- 13,44 ---- | |
namespace NArchive { | |
namespace NTar { | |
+ static int CompareTarUpdateItems(void *const *x, void *const *y, void *) | |
+ { | |
+ const CUpdateItem* p1 = *((const CUpdateItem**)x); | |
+ const CUpdateItem* p2 = *((const CUpdateItem**)y); | |
+ | |
+ if(!(p1->NewProps || p2->NewProps)) //Both are existing files | |
+ return MyCompare(p1->IndexInArchive, p2->IndexInArchive); | |
+ | |
+ if(p1->NewProps!=p2->NewProps) | |
+ return p1->NewProps?1:-1; //We want the existing file on the top | |
+ | |
+ return 0; | |
+ } | |
+ | |
HRESULT UpdateArchive(IInStream *inStream, ISequentialOutStream *outStream, | |
const CObjectVector<NArchive::NTar::CItemEx> &inputItems, | |
! const CObjectVector<CUpdateItem> &updateItemsUnsorted, | |
IArchiveUpdateCallback *updateCallback) | |
{ | |
COutArchive outArchive; | |
outArchive.Create(outStream); | |
+ | |
+ //Sort the update items to make sure that the existing files | |
+ //are handled first. This preserves the ordering of pax headers. | |
+ CObjectVector<CUpdateItem> updateItems(updateItemsUnsorted); | |
+ updateItems.Sort(CompareTarUpdateItems, (void*)NULL); | |
UInt64 complexity = 0; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment