From 53f3739c7ff34e33358f5837ec0348e87334dada Mon Sep 17 00:00:00 2001 From: sisong Date: Thu, 11 Jul 2024 14:51:41 +0800 Subject: [PATCH 1/4] when SFX run with default options, now support oldPath is empty or current directory(before only empty); close #387 --- .../xcode/hpatchz.xcodeproj/project.pbxproj | 6 ---- hpatchz.c | 33 +++++++++++-------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/builds/xcode/hpatchz.xcodeproj/project.pbxproj b/builds/xcode/hpatchz.xcodeproj/project.pbxproj index b09ead6e..90f33364 100644 --- a/builds/xcode/hpatchz.xcodeproj/project.pbxproj +++ b/builds/xcode/hpatchz.xcodeproj/project.pbxproj @@ -363,11 +363,8 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_WEAK = YES; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; MACOSX_DEPLOYMENT_TARGET = 10.9; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = ""; }; name = Debug; }; @@ -375,11 +372,8 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_WEAK = YES; - CODE_SIGN_STYLE = Automatic; - DEVELOPMENT_TEAM = ""; MACOSX_DEPLOYMENT_TARGET = 10.9; PRODUCT_NAME = "$(TARGET_NAME)"; - PROVISIONING_PROFILE_SPECIFIER = ""; }; name = Release; }; diff --git a/hpatchz.c b/hpatchz.c index fe078df8..f52e59db 100644 --- a/hpatchz.c +++ b/hpatchz.c @@ -148,6 +148,14 @@ static void printHelpInfo(){ int hpatch_printFilesInfos(int fileCount,const char* fileNames[]); +#if (_IS_NEED_SFX) +# ifdef _WIN32 + #define kSFX_curDefaultPath ".\\" +# else + #define kSFX_curDefaultPath "./" +# endif +#endif + static void printUsage(){ printVersion(); printf("\n"); @@ -156,12 +164,8 @@ static void printUsage(){ #if (_IS_NEED_SFX) "create SFX: hpatchz [-X-exe#selfExecuteFile] diffFile -X#outSelfExtractArchive\n" "run SFX: selfExtractArchive [[options] oldPath -X outNewPath]\n" - "extract SFX: selfExtractArchive (same as: selfExtractArchive -f \"\" -X " -# ifdef _WIN32 - "\".\\\")\n" -# else - "\"./\")\n" -# endif + "extract SFX: selfExtractArchive (same as: $selfExtractArchive -f {\"\"|\"" kSFX_curDefaultPath "\"} -X " + "\"" kSFX_curDefaultPath "\")\n" #endif " if oldPath is empty input parameter \"\"\n" "options:\n" @@ -611,11 +615,7 @@ int hpatch_cmd_line(int argc, const char * argv[]){ const char* diffFileName=0; const char* outNewPath =0; #if (_IS_NEED_SFX) -# ifdef _WIN32 - const char* kSFX_curDefaultPath=".\\"; -# else - const char* kSFX_curDefaultPath="./"; -# endif + hpatch_BOOL isSfxDefaultPath=hpatch_FALSE; const char* kSFX_emptyPath=""; #endif #if (_IS_NEED_DIR_DIFF_PATCH) @@ -634,6 +634,7 @@ int hpatch_cmd_line(int argc, const char * argv[]){ if (arg_values_size==0){//autoExtractSFX oldPath =kSFX_emptyPath; outNewPath =kSFX_curDefaultPath; + isSfxDefaultPath=hpatch_TRUE; }else{ oldPath =arg_values[0]; outNewPath =arg_values[1]; @@ -647,7 +648,6 @@ int hpatch_cmd_line(int argc, const char * argv[]){ outNewPath =arg_values[2]; } - isSamePath=hpatch_getIsSamePath(oldPath,outNewPath); _return_check(!hpatch_getIsSamePath(oldPath,diffFileName), HPATCH_PATHTYPE_ERROR,"oldPath diffFile same path"); _return_check(!hpatch_getIsSamePath(outNewPath,diffFileName), @@ -659,13 +659,18 @@ int hpatch_cmd_line(int argc, const char * argv[]){ _return_check(outNewPathType==kPathType_notExist, HPATCH_PATHTYPE_ERROR,"outNewPath already exists, overwrite"); } - if (isSamePath) - _return_check(isForceOverwrite,HPATCH_PATHTYPE_ERROR,"oldPath outNewPath same path, overwrite"); #if (_IS_NEED_DIR_DIFF_PATCH) _return_check(getDirDiffInfoByFile(&dirDiffInfo,diffFileName,diffDataOffert,diffDataSize), HPATCH_OPENREAD_ERROR,"input diffFile open read"); isOutDir=(dirDiffInfo.isDirDiff)&&(dirDiffInfo.newPathIsDir); + #if (_IS_NEED_SFX) + if (isSfxDefaultPath && (dirDiffInfo.isDirDiff&&dirDiffInfo.oldPathIsDir)) + oldPath=kSFX_curDefaultPath; + #endif #endif + isSamePath=hpatch_getIsSamePath(oldPath,outNewPath); + if (isSamePath) + _return_check(isForceOverwrite,HPATCH_PATHTYPE_ERROR,"oldPath outNewPath same path, overwrite"); if (!isSamePath){ // out new file or new dir #if (_IS_NEED_DIR_DIFF_PATCH) if (dirDiffInfo.isDirDiff){ From 3b02350fed90da6e61e3e1762bbe80a5e27b5701 Mon Sep 17 00:00:00 2001 From: sisong Date: Thu, 11 Jul 2024 19:42:17 +0800 Subject: [PATCH 2/4] support "hdiffz -BSD -SD" create diffFile new format: endsley/bsdiff ; recode hpatch_BsDiffInfo.isEsBsd to hpatch_BsDiffInfo.isEndsleyBsdiff; --- bsdiff_wrapper/bsdiff_wrapper.cpp | 132 +++++++++++++++++++++++++----- bsdiff_wrapper/bsdiff_wrapper.h | 10 +-- bsdiff_wrapper/bspatch_wrapper.c | 20 +++-- bsdiff_wrapper/bspatch_wrapper.h | 6 +- hdiffz.cpp | 50 ++++++----- hpatchz.c | 6 +- 6 files changed, 164 insertions(+), 60 deletions(-) diff --git a/bsdiff_wrapper/bsdiff_wrapper.cpp b/bsdiff_wrapper/bsdiff_wrapper.cpp index e3d21c47..88c871fa 100644 --- a/bsdiff_wrapper/bsdiff_wrapper.cpp +++ b/bsdiff_wrapper/bsdiff_wrapper.cpp @@ -38,6 +38,7 @@ #endif #define _check(value,info) { if (!(value)) { throw std::runtime_error(info); } } static const char* kBsDiffVersionType="BSDIFF40"; +static const char* kEsBsDiffVersionType = "ENDSLEY/BSDIFF43"; namespace hdiff_private{ static inline void pushUInt64(std::vector& buf,hpatch_uint64_t v){ @@ -103,23 +104,115 @@ namespace hdiff_private{ } }; + + struct TInterlaceStream:public hpatch_TStreamInput{ + explicit TInterlaceStream(const TCovers& _covers,TCtrlStream& _ctrlStream, + TNewDataSubDiffStream& _subStream,TNewDataDiffStream& _diffStream) + :curPos(0),curi(0),covers(_covers), + curCtrlPos(0),curSubPos(0),curDiffPos(0),curCtrlLen(0),curSubLen(0),curDiffLen(0), + ctrlStream(_ctrlStream),subStream(_subStream),diffStream(_diffStream){ + streamImport=this; + read=_read; + streamSize=ctrlStream.streamSize+subStream.streamSize+diffStream.streamSize; + } + private: + hpatch_StreamPos_t curPos; + size_t curi; + const TCovers& covers; + hpatch_StreamPos_t curCtrlPos; + hpatch_StreamPos_t curSubPos; + hpatch_StreamPos_t curDiffPos; + size_t curCtrlLen; + size_t curSubLen; + size_t curDiffLen; + TCtrlStream& ctrlStream; + TNewDataSubDiffStream& subStream; + TNewDataDiffStream& diffStream; + void _update(){ + if (curi+10){ + if (curCtrlLen+curSubLen+curDiffLen==0){ + _update(); + _check(curCtrlLen+curSubLen+curDiffLen>0,"TInterlaceStream _update"); + } + + hpatch_StreamPos_t* dataPos; + size_t* dataLen; + hpatch_TStreamInput* dataStream; + if (curCtrlLen>0){ + dataPos=&curCtrlPos; + dataLen=&curCtrlLen; + dataStream=&ctrlStream; + }else if (curSubLen>0){ + dataPos=&curSubPos; + dataLen=&curSubLen; + dataStream=&subStream; + }else{ + assert(curDiffLen>0); + dataPos=&curDiffPos; + dataLen=&curDiffLen; + dataStream=&diffStream; + } + + size_t cLen=(*dataLen); + if (cLen>readLen) cLen=readLen; + _check(dataStream->read(dataStream,*dataPos,out_data,out_data+cLen),"TInterlaceStream dataStream->read") + out_data+=cLen; + readLen-=cLen; + (*dataPos)+=cLen; + (*dataLen)-=cLen; + } + return hpatch_TRUE; + } + static hpatch_BOOL _read(const hpatch_TStreamInput* stream,hpatch_StreamPos_t readFromPos, + unsigned char* out_data,unsigned char* out_data_end){ + TInterlaceStream* self=(TInterlaceStream*)stream->streamImport; + return self->readTo(readFromPos,out_data,out_data_end); + } + }; + static void serialize_bsdiff(const hpatch_TStreamInput* newData,const hpatch_TStreamInput* oldData, const TCovers& covers,const hpatch_TStreamOutput* out_diff, - const hdiff_TCompress* compressPlugin,bool isZeroSubDiff=false){ + const hdiff_TCompress* compressPlugin,bool isEndsleyBsdiff,bool isZeroSubDiff=false){ std::vector buf; TDiffStream outDiff(out_diff); size_t ctrlDataSize_pos; - size_t subDataSize_pos; {//head buf.clear(); - pushCStr(buf,kBsDiffVersionType); + pushCStr(buf,isEndsleyBsdiff?kEsBsDiffVersionType:kBsDiffVersionType); ctrlDataSize_pos=buf.size(); - pushUInt64(buf,0); //ctrlDataSize - subDataSize_pos=buf.size(); - pushUInt64(buf,0); //subDataSize + if (!isEndsleyBsdiff){ + pushUInt64(buf,0); //ctrlDataSize + pushUInt64(buf,0); //subDataSize + } pushUInt64(buf,newData->streamSize); outDiff.pushBack(buf.data(),buf.size()); } + + if (isEndsleyBsdiff){ + // endsley/bsdiff + TCtrlStream ctrlStream(covers); + TNewDataSubDiffStream subStream(newData,oldData,covers,true,isZeroSubDiff); + TNewDataDiffStream diffStream(covers,newData); + + TInterlaceStream interlaceStream(covers,ctrlStream,subStream,diffStream); + outDiff.pushStream(&interlaceStream,compressPlugin,true); + return; + } + //else bsdiff4 {//ctrl data TCtrlStream ctrlStream(covers); @@ -135,6 +228,7 @@ static void serialize_bsdiff(const hpatch_TStreamInput* newData,const hpatch_TSt TNewDataSubDiffStream subStream(newData,oldData,covers,true,isZeroSubDiff); hpatch_StreamPos_t subDataSize=outDiff.pushStream(&subStream,compressPlugin,true); + size_t subDataSize_pos=ctrlDataSize_pos+8; buf.clear(); pushUInt64(buf,subDataSize);//update subDataSize _check(out_diff->write(out_diff,subDataSize_pos,buf.data(), @@ -173,7 +267,7 @@ static void _to_bsdiff_covers(std::vector<_TCover>& covers,_TSize newSize){ void _create_bsdiff(const unsigned char* newData,const unsigned char* cur_newData_end,const unsigned char* newData_end, const unsigned char* oldData,const unsigned char* cur_oldData_end,const unsigned char* oldData_end, const hpatch_TStreamOutput* out_diff,const hdiff_TCompress* compressPlugin, - int kMinSingleMatchScore,bool isUseBigCacheMatch, + bool isEndsleyBsdiff,int kMinSingleMatchScore,bool isUseBigCacheMatch, ICoverLinesListener* coverLinesListener,size_t threadNum){ std::vector covers; get_match_covers_by_sstring(newData,cur_newData_end,oldData,cur_oldData_end,covers, @@ -188,7 +282,7 @@ void _create_bsdiff(const unsigned char* newData,const unsigned char* cur_newDat mem_as_hStreamInput(&newStream,newData,newData_end); mem_as_hStreamInput(&oldStream,oldData,oldData_end); - serialize_bsdiff(&newStream,&oldStream,_covers,out_diff,compressPlugin); + serialize_bsdiff(&newStream,&oldStream,_covers,out_diff,compressPlugin,isEndsleyBsdiff); } }//end namespace hdiff_private @@ -198,15 +292,15 @@ using namespace hdiff_private; void create_bsdiff(const unsigned char* newData,const unsigned char* newData_end, const unsigned char* oldData,const unsigned char* oldData_end, const hpatch_TStreamOutput* out_diff,const hdiff_TCompress* compressPlugin, - int kMinSingleMatchScore,bool isUseBigCacheMatch, + bool isEndsleyBsdiff,int kMinSingleMatchScore,bool isUseBigCacheMatch, ICoverLinesListener* coverLinesListener,size_t threadNum){ _create_bsdiff(newData,newData_end,newData_end,oldData,oldData_end,oldData_end, - out_diff,compressPlugin,kMinSingleMatchScore,isUseBigCacheMatch, + out_diff,compressPlugin,isEndsleyBsdiff,kMinSingleMatchScore,isUseBigCacheMatch, coverLinesListener,threadNum); } void create_bsdiff(const hpatch_TStreamInput* newData,const hpatch_TStreamInput* oldData, const hpatch_TStreamOutput* out_diff,const hdiff_TCompress* compressPlugin, - int kMinSingleMatchScore,bool isUseBigCacheMatch, + bool isEndsleyBsdiff,int kMinSingleMatchScore,bool isUseBigCacheMatch, ICoverLinesListener* coverLinesListener,size_t threadNum){ TAutoMem oldAndNewData; loadOldAndNewStream(oldAndNewData,oldData,newData); @@ -215,13 +309,13 @@ void create_bsdiff(const hpatch_TStreamInput* newData,const hpatch_TStreamInput* unsigned char* pNewData=pOldData+old_size; unsigned char* pNewDataEnd=pNewData+(size_t)newData->streamSize; _create_bsdiff(pNewData,pNewDataEnd,pNewDataEnd,pOldData,pOldData+old_size,pOldData+old_size, - out_diff,compressPlugin,kMinSingleMatchScore,isUseBigCacheMatch, + out_diff,compressPlugin,isEndsleyBsdiff,kMinSingleMatchScore,isUseBigCacheMatch, coverLinesListener,threadNum); } void create_bsdiff_stream(const hpatch_TStreamInput* newData,const hpatch_TStreamInput* oldData, const hpatch_TStreamOutput* out_diff,const hdiff_TCompress* compressPlugin, - size_t kMatchBlockSize,const hdiff_TMTSets_s* mtsets){ + bool isEndsleyBsdiff,size_t kMatchBlockSize,const hdiff_TMTSets_s* mtsets){ TCoversBuf covers(newData->streamSize,oldData->streamSize); get_match_covers_by_block(newData,oldData,&covers,kMatchBlockSize,mtsets); if (covers._isCover32) @@ -229,28 +323,28 @@ void create_bsdiff_stream(const hpatch_TStreamInput* newData,const hpatch_TStrea else _to_bsdiff_covers(covers.m_covers_larger,newData->streamSize); covers.update(); - serialize_bsdiff(newData,oldData,covers,out_diff,compressPlugin,true); + serialize_bsdiff(newData,oldData,covers,out_diff,compressPlugin,isEndsleyBsdiff,true); } void create_bsdiff_block(unsigned char* newData,unsigned char* newData_end, unsigned char* oldData,unsigned char* oldData_end, const hpatch_TStreamOutput* out_diff,const hdiff_TCompress* compressPlugin, - int kMinSingleMatchScore,bool isUseBigCacheMatch, + bool isEndsleyBsdiff,int kMinSingleMatchScore,bool isUseBigCacheMatch, size_t matchBlockSize,size_t threadNum){ if (matchBlockSize==0){ _create_bsdiff(newData,newData_end,newData_end,oldData,oldData_end,oldData_end, - out_diff,compressPlugin,kMinSingleMatchScore,isUseBigCacheMatch,0,threadNum); + out_diff,compressPlugin,isEndsleyBsdiff,kMinSingleMatchScore,isUseBigCacheMatch,0,threadNum); return; } TCoversOptimMB coversOp(newData,newData_end,oldData,oldData_end,matchBlockSize,threadNum); _create_bsdiff(newData,coversOp.matchBlock->newData_end_cur,newData_end, oldData,coversOp.matchBlock->oldData_end_cur,oldData_end, - out_diff,compressPlugin,kMinSingleMatchScore,isUseBigCacheMatch,&coversOp,threadNum); + out_diff,compressPlugin,isEndsleyBsdiff,kMinSingleMatchScore,isUseBigCacheMatch,&coversOp,threadNum); } void create_bsdiff_block(const hpatch_TStreamInput* newData,const hpatch_TStreamInput* oldData, const hpatch_TStreamOutput* out_diff,const hdiff_TCompress* compressPlugin, - int kMinSingleMatchScore,bool isUseBigCacheMatch, + bool isEndsleyBsdiff,int kMinSingleMatchScore,bool isUseBigCacheMatch, size_t matchBlockSize,size_t threadNum){ TAutoMem oldAndNewData; loadOldAndNewStream(oldAndNewData,oldData,newData); @@ -258,7 +352,7 @@ void create_bsdiff_block(const hpatch_TStreamInput* newData,const hpatch_TStream unsigned char* pOldData=oldAndNewData.data(); unsigned char* pNewData=pOldData+old_size; create_bsdiff_block(pNewData,pNewData+(size_t)newData->streamSize,pOldData,pOldData+old_size, - out_diff,compressPlugin,kMinSingleMatchScore,isUseBigCacheMatch, + out_diff,compressPlugin,isEndsleyBsdiff,kMinSingleMatchScore,isUseBigCacheMatch, matchBlockSize,threadNum); } diff --git a/bsdiff_wrapper/bsdiff_wrapper.h b/bsdiff_wrapper/bsdiff_wrapper.h index 4daf10f8..c5662244 100644 --- a/bsdiff_wrapper/bsdiff_wrapper.h +++ b/bsdiff_wrapper/bsdiff_wrapper.h @@ -33,19 +33,19 @@ void create_bsdiff(const unsigned char* newData,const unsigned char* newData_end, const unsigned char* oldData,const unsigned char* oldData_end, const hpatch_TStreamOutput* out_diff,const hdiff_TCompress* compressPlugin, - int kMinSingleMatchScore=kMinSingleMatchScore_default, + bool isEndsleyBsdiff=false,int kMinSingleMatchScore=kMinSingleMatchScore_default, bool isUseBigCacheMatch=false,ICoverLinesListener* coverLinesListener=0, size_t threadNum=1); void create_bsdiff(const hpatch_TStreamInput* newData,const hpatch_TStreamInput* oldData, const hpatch_TStreamOutput* out_diff,const hdiff_TCompress* compressPlugin, - int kMinSingleMatchScore=kMinSingleMatchScore_default, + bool isEndsleyBsdiff=false,int kMinSingleMatchScore=kMinSingleMatchScore_default, bool isUseBigCacheMatch=false,ICoverLinesListener* coverLinesListener=0, size_t threadNum=1); // create diffFile by stream compatible with bsdiff4 void create_bsdiff_stream(const hpatch_TStreamInput* newData,const hpatch_TStreamInput* oldData, const hpatch_TStreamOutput* out_diff,const hdiff_TCompress* compressPlugin, - size_t kMatchBlockSize=kMatchBlockSize_default,const hdiff_TMTSets_s* mtsets=0); + bool isEndsleyBsdiff=false,size_t kMatchBlockSize=kMatchBlockSize_default,const hdiff_TMTSets_s* mtsets=0); bool check_bsdiff(const hpatch_TStreamInput* newData,const hpatch_TStreamInput* oldData, const hpatch_TStreamInput* diffData,hpatch_TDecompress* decompressPlugin); @@ -59,13 +59,13 @@ bool check_bsdiff(const unsigned char* newData,const unsigned char* newData_end, void create_bsdiff_block(unsigned char* newData,unsigned char* newData_end, unsigned char* oldData,unsigned char* oldData_end, const hpatch_TStreamOutput* out_diff,const hdiff_TCompress* compressPlugin, - int kMinSingleMatchScore=kMinSingleMatchScore_default, + bool isEndsleyBsdiff=false,int kMinSingleMatchScore=kMinSingleMatchScore_default, bool isUseBigCacheMatch=false, size_t matchBlockSize=kDefaultFastMatchBlockSize, size_t threadNum=1); void create_bsdiff_block(const hpatch_TStreamInput* newData,const hpatch_TStreamInput* oldData, const hpatch_TStreamOutput* out_diff,const hdiff_TCompress* compressPlugin, - int kMinSingleMatchScore=kMinSingleMatchScore_default, + bool isEndsleyBsdiff=false,int kMinSingleMatchScore=kMinSingleMatchScore_default, bool isUseBigCacheMatch=false, size_t matchBlockSize=kDefaultFastMatchBlockSize, size_t threadNum=1); diff --git a/bsdiff_wrapper/bspatch_wrapper.c b/bsdiff_wrapper/bspatch_wrapper.c index 30bf48e3..29b650de 100644 --- a/bsdiff_wrapper/bspatch_wrapper.c +++ b/bsdiff_wrapper/bspatch_wrapper.c @@ -73,15 +73,15 @@ hpatch_BOOL getBsDiffInfo(hpatch_BsDiffInfo* out_diffinfo,const hpatch_TStreamIn if (!diffStream->read(diffStream,0,buf,buf+kBsDiffHeadLen)) // must bz2 compressed size>=8 return _hpatch_FALSE; if (0==memcmp(buf,kBsDiffVersionType,kBsDiffVersionTypeLen)){ - out_diffinfo->isEsBsd=hpatch_FALSE; + out_diffinfo->isEndsleyBsdiff=hpatch_FALSE; out_diffinfo->headSize=kBsDiffHeadLen; }else if (0==memcmp(buf,kEsBsDiffVersionType,kEsBsDiffVersionTypeLen)){ - out_diffinfo->isEsBsd=hpatch_TRUE; + out_diffinfo->isEndsleyBsdiff=hpatch_TRUE; out_diffinfo->headSize=kEsBsDiffHeadLen; }else{ return _hpatch_FALSE; } - if (out_diffinfo->isEsBsd){ + if (out_diffinfo->isEndsleyBsdiff){ buf+=kEsBsDiffVersionTypeLen; out_diffinfo->ctrlDataSize=0; out_diffinfo->subDataSize =0; @@ -103,15 +103,17 @@ hpatch_BOOL getBsDiffInfo_mem(hpatch_BsDiffInfo* out_diffinfo,const unsigned cha return getBsDiffInfo(out_diffinfo,&diffStream); } -hpatch_BOOL getIsBsDiff(const hpatch_TStreamInput* diffData){ +hpatch_BOOL getIsBsDiff(const hpatch_TStreamInput* diffData,hpatch_BOOL* out_isSingleCompressedDiff){ hpatch_BsDiffInfo diffinfo; - return getBsDiffInfo(&diffinfo,diffData); + hpatch_BOOL result=getBsDiffInfo(&diffinfo,diffData); + if (result&&out_isSingleCompressedDiff) *out_isSingleCompressedDiff=diffinfo.isEndsleyBsdiff; + return result; } -hpatch_BOOL getIsBsDiff_mem(const unsigned char* diffData,const unsigned char* diffData_end){ +hpatch_BOOL getIsBsDiff_mem(const unsigned char* diffData,const unsigned char* diffData_end,hpatch_BOOL* out_isSingleCompressedDiff){ hpatch_TStreamInput diffStream; mem_as_hStreamInput(&diffStream,diffData,diffData_end); - return getIsBsDiff(&diffStream); + return getIsBsDiff(&diffStream,out_isSingleCompressedDiff); } static hpatch_BOOL _patch_add_old_with_sub(_TOutStreamCache* outCache,TStreamCacheClip* subClip, @@ -226,11 +228,11 @@ hpatch_BOOL bspatch_with_cache(const hpatch_TStreamOutput* out_newData, temp_cache+=cacheSize; cacheSize=(temp_cache_end-temp_cache); } - cacheSize=cacheSize/(diffInfo.isEsBsd?_kCacheBsDecCount-2:_kCacheBsDecCount); + cacheSize=cacheSize/(diffInfo.isEndsleyBsdiff?_kCacheBsDecCount-2:_kCacheBsDecCount); if (cacheSize<8) return _hpatch_FALSE; diffPos0=diffInfo.headSize; - if (diffInfo.isEsBsd){ + if (diffInfo.isEndsleyBsdiff){ if (!getStreamClip(&newDataDiffClip,&decompressers[0], _kUnknowMaxSize,compressedDiff->streamSize-diffPos0,compressedDiff,&diffPos0, decompressPlugin,temp_cache,cacheSize)) _clear_return(_hpatch_FALSE); diff --git a/bsdiff_wrapper/bspatch_wrapper.h b/bsdiff_wrapper/bspatch_wrapper.h index 2701ca9c..9af517ad 100644 --- a/bsdiff_wrapper/bspatch_wrapper.h +++ b/bsdiff_wrapper/bspatch_wrapper.h @@ -37,11 +37,11 @@ typedef struct hpatch_BsDiffInfo{ hpatch_StreamPos_t ctrlDataSize; hpatch_StreamPos_t subDataSize; hpatch_StreamPos_t newDataSize; - hpatch_BOOL isEsBsd; + hpatch_BOOL isEndsleyBsdiff; } hpatch_BsDiffInfo; -hpatch_BOOL getIsBsDiff(const hpatch_TStreamInput* diffData); -hpatch_BOOL getIsBsDiff_mem(const unsigned char* diffData,const unsigned char* diffData_end); +hpatch_BOOL getIsBsDiff(const hpatch_TStreamInput* diffData,hpatch_BOOL* out_isSingleCompressedDiff); +hpatch_BOOL getIsBsDiff_mem(const unsigned char* diffData,const unsigned char* diffData_end,hpatch_BOOL* out_isSingleCompressedDiff); hpatch_BOOL getBsDiffInfo(hpatch_BsDiffInfo* out_diffinfo,const hpatch_TStreamInput* diffStream); hpatch_BOOL getBsDiffInfo_mem(hpatch_BsDiffInfo* out_diffinfo,const unsigned char* diffData,const unsigned char* diffData_end); diff --git a/hdiffz.cpp b/hdiffz.cpp index b3cd5946..04ad924b 100644 --- a/hdiffz.cpp +++ b/hdiffz.cpp @@ -87,7 +87,7 @@ # include "bsdiff_wrapper/bsdiff_wrapper.h" # include "bsdiff_wrapper/bspatch_wrapper.h" # ifndef _CompressPlugin_bz2 -# define _CompressPlugin_bz2 //bsdiff4 need bz2 +# define _CompressPlugin_bz2 //bsdiff need bz2 # endif #endif #if (_IS_NEED_VCDIFF) @@ -184,6 +184,8 @@ static void printUsage(){ #if (_IS_NEED_BSDIFF) " -BSD\n" " create diffFile compatible with bsdiff4, unsupport input directory(folder).\n" + " support run with -SD (not used stepSize), then create single compressed\n" + " diffFile compatible with endsley/bsdiff (https://github.com/mendsley/bsdiff).\n" #endif #if (_IS_NEED_VCDIFF) # ifdef _CompressPlugin_7zXZ @@ -477,7 +479,7 @@ static hpatch_BOOL _getIsBsDiffFile(const char* diffFileName) { hpatch_TFileStreamInput diffData; hpatch_TFileStreamInput_init(&diffData); if (!hpatch_TFileStreamInput_open(&diffData, diffFileName)) return hpatch_FALSE; - hpatch_BOOL result=getIsBsDiff(&diffData.base); + hpatch_BOOL result=getIsBsDiff(&diffData.base,0); if (!hpatch_TFileStreamInput_close(&diffData)) return hpatch_FALSE; return result; } @@ -1055,9 +1057,8 @@ int hdiff_cmd_line(int argc, const char * argv[]){ if (diffSets.isBsDiff==_kNULL_VALUE) diffSets.isBsDiff=hpatch_FALSE; if (diffSets.isBsDiff){ - _options_check(!diffSets.isSingleCompressedDiff,"-SD -BSD -VCD can only set one"); if (compressPlugin!=0){ - _options_check(0==strcmp(compressPlugin->compressType(),"bz2"),"bsdiff4 must run with -c-bz2"); + _options_check(0==strcmp(compressPlugin->compressType(),"bz2"),"bsdiff must run with -c-bz2"); }else{ static TCompressPlugin_bz2 _bz2CompressPlugin=bz2CompressPlugin; compressPlugin=&_bz2CompressPlugin.base; @@ -1068,9 +1069,9 @@ int hdiff_cmd_line(int argc, const char * argv[]){ if (diffSets.isVcDiff==_kNULL_VALUE) diffSets.isVcDiff=hpatch_FALSE; if (diffSets.isVcDiff){ - _options_check(!diffSets.isSingleCompressedDiff,"-SD -BSD -VCD can only set one"); + _options_check(!diffSets.isSingleCompressedDiff,"-SD -VCD can only set one"); #if (_IS_NEED_BSDIFF) - _options_check(!diffSets.isBsDiff,"-SD -BSD -VCD can only set one"); + _options_check(!diffSets.isBsDiff,"-BSD -VCD can only set one"); #endif } #endif @@ -1184,7 +1185,7 @@ int hdiff_cmd_line(int argc, const char * argv[]){ #if (_IS_NEED_DIR_DIFF_PATCH) if (isUseDirDiff){ #if (_IS_NEED_BSDIFF) - _options_check(!diffSets.isBsDiff,"bsdiff4 unsupport dir diff"); + _options_check(!diffSets.isBsDiff,"bsdiff unsupport dir diff"); #endif #if (_IS_NEED_VCDIFF) _options_check(!diffSets.isVcDiff,"VCDIFF unsupport dir diff"); @@ -1395,8 +1396,8 @@ static int hdiff_in_mem(const char* oldFileName,const char* newFileName,const ch #if (_IS_NEED_BSDIFF) if (diffSets.isBsDiff){ create_bsdiff_block(newMem.data(),newMem.data_end(),oldMem.data(),oldMem.data_end(),&diffData_out.base, - compressPlugin,(int)diffSets.matchScore,diffSets.isUseBigCacheMatch, - diffSets.matchBlockSize,diffSets.threadNum); + compressPlugin,diffSets.isSingleCompressedDiff,(int)diffSets.matchScore, + diffSets.isUseBigCacheMatch,diffSets.matchBlockSize,diffSets.threadNum); }else #endif #if (_IS_NEED_VCDIFF) @@ -1461,11 +1462,11 @@ static int hdiff_in_mem(const char* oldFileName,const char* newFileName,const ch if (!diffSets.isDoDiff) printf("test single compressed diffData!\n"); #if (_IS_NEED_BSDIFF) - }else if (getIsBsDiff_mem(diffMem.data(),diffMem.data_end())){ + }else if (getIsBsDiff_mem(diffMem.data(),diffMem.data_end(),&isSingleCompressedDiff)){ *saved_decompressPlugin=_bz2DecompressPlugin_unsz; isBsDiff=hpatch_TRUE; if (!diffSets.isDoDiff) - printf("test bsdiff4's diffData!\n"); + printf(isSingleCompressedDiff?"test endsley/bsdiff's diffData!\n":"test bsdiff4's diffData!\n"); #endif #if (_IS_NEED_VCDIFF) }else if (getVcDiffInfo_mem(&vcdiffInfo,diffMem.data(),diffMem.data_end(),hpatch_FALSE)){ @@ -1487,19 +1488,21 @@ static int hdiff_in_mem(const char* oldFileName,const char* newFileName,const ch } bool diffrt; - if (isSingleCompressedDiff) - diffrt=check_single_compressed_diff(newMem.data(),newMem.data_end(),oldMem.data(),oldMem.data_end(), - diffMem.data(),diffMem.data_end(),saved_decompressPlugin); #if (_IS_NEED_BSDIFF) - else if (isBsDiff) + if (isBsDiff) diffrt=check_bsdiff(newMem.data(),newMem.data_end(),oldMem.data(),oldMem.data_end(), diffMem.data(),diffMem.data_end(),saved_decompressPlugin); + else #endif #if (_IS_NEED_VCDIFF) - else if (isVcDiff) + if (isVcDiff) diffrt=check_vcdiff(newMem.data(),newMem.data_end(),oldMem.data(),oldMem.data_end(), diffMem.data(),diffMem.data_end(),saved_decompressPlugin); + else #endif + if (isSingleCompressedDiff) + diffrt=check_single_compressed_diff(newMem.data(),newMem.data_end(),oldMem.data(),oldMem.data_end(), + diffMem.data(),diffMem.data_end(),saved_decompressPlugin); else diffrt=check_compressed_diff(newMem.data(),newMem.data_end(),oldMem.data(),oldMem.data_end(), diffMem.data(),diffMem.data_end(),saved_decompressPlugin); @@ -1544,7 +1547,8 @@ static int hdiff_by_stream(const char* oldFileName,const char* newFileName,const #if (_IS_NEED_BSDIFF) if (diffSets.isBsDiff){ create_bsdiff_stream(&newData.base,&oldData.base, &diffData_out.base, - compressPlugin,diffSets.matchBlockSize,&mtsets); + compressPlugin,diffSets.isSingleCompressedDiff, + diffSets.matchBlockSize,&mtsets); }else #endif #if (_IS_NEED_VCDIFF) @@ -1605,11 +1609,11 @@ static int hdiff_by_stream(const char* oldFileName,const char* newFileName,const if (!diffSets.isDoDiff) printf("test single compressed diffData!\n"); #if (_IS_NEED_BSDIFF) - }else if (getIsBsDiff(&diffData_in.base)){ + }else if (getIsBsDiff(&diffData_in.base,&isSingleCompressedDiff)){ *saved_decompressPlugin=_bz2DecompressPlugin_unsz; isBsDiff=hpatch_TRUE; if (!diffSets.isDoDiff) - printf("test bsdiff4's diffData!\n"); + printf(isSingleCompressedDiff?"test endsley/bsdiff's diffData!\n":"test bsdiff4's diffData!\n"); #endif #if (_IS_NEED_VCDIFF) }else if (getVcDiffInfo(&vcdiffInfo,&diffData_in.base,hpatch_FALSE)){ @@ -1667,11 +1671,15 @@ int hdiff(const char* oldFileName,const char* newFileName,const char* outDiffFil const char* compressType=""; if (compressPlugin) compressType=compressPlugin->compressType(); printf("hdiffz run with compress plugin: \"%s\"\n",compressType); - if (diffSets.isSingleCompressedDiff) + if (diffSets.isSingleCompressedDiff){ + #if (_IS_NEED_BSDIFF) + if (!diffSets.isBsDiff) + #endif printf("create single compressed diffData!\n"); + } #if (_IS_NEED_BSDIFF) if (diffSets.isBsDiff) - printf("create bsdiff4 diffData!\n"); + printf(diffSets.isSingleCompressedDiff?"create endsley/bsdiff diffData!\n":"create bsdiff4 diffData!\n"); #endif #if (_IS_NEED_VCDIFF) if (diffSets.isVcDiff) diff --git a/hpatchz.c b/hpatchz.c index f52e59db..9c1824ad 100644 --- a/hpatchz.c +++ b/hpatchz.c @@ -947,7 +947,7 @@ static int _getHDiffInfos(_THDiffInfos* out_diffInfos,const hpatch_TFileStreamIn *decompressPlugin=_bz2DecompressPlugin_unsz; decompressPlugin->decError=hpatch_dec_ok; memcpy(diffInfo->compressType,bsCompressType,strlen(bsCompressType)+1); - diffInfo->compressedCount=out_diffInfos->bsdiffInfo.isEsBsd?1:3; + diffInfo->compressedCount=out_diffInfos->bsdiffInfo.isEndsleyBsdiff?1:3; diffInfo->newDataSize=out_diffInfos->bsdiffInfo.newDataSize; diffInfo->oldDataSize=_kUnavailableSize; //not saved oldDataSize out_diffInfos->isBsDiff=hpatch_TRUE; @@ -991,8 +991,8 @@ static void _printHDiffInfos(const _THDiffInfos* diffInfos,hpatch_BOOL isInDirDi #endif #if (_IS_NEED_BSDIFF) if (diffInfos->isBsDiff){ - if (diffInfos->bsdiffInfo.isEsBsd) - typeTag="BSDiff (ENDSLEY)"; + if (diffInfos->bsdiffInfo.isEndsleyBsdiff) + typeTag="BSDiff (endsley/bsdiff)"; else typeTag="BSDiff"; } From a2661d185a43955d0fc30e3fb81401ca537d9432 Mon Sep 17 00:00:00 2001 From: sisong Date: Fri, 12 Jul 2024 12:15:31 +0800 Subject: [PATCH 3/4] hdiffz cmline add -neq option: for check oldData!=newData; fix & recode hpatchz SFX logic; --- dirDiffPatch/dir_diff/dir_diff.cpp | 37 ++++++++++++++++++++++++++---- dirDiffPatch/dir_diff/dir_diff.h | 1 + hdiffz.cpp | 33 +++++++++++++++++++++----- hpatchz.c | 14 +++++------ 4 files changed, 68 insertions(+), 17 deletions(-) diff --git a/dirDiffPatch/dir_diff/dir_diff.cpp b/dirDiffPatch/dir_diff/dir_diff.cpp index e62e15e2..91510c27 100644 --- a/dirDiffPatch/dir_diff/dir_diff.cpp +++ b/dirDiffPatch/dir_diff/dir_diff.cpp @@ -97,6 +97,14 @@ static bool fileData_isSame(const std::string& file_x,const std::string& file_y, return true; } +static bool fileName_isSame(const std::string& file_x,const std::string& rootPath_x, + const std::string& file_y,const std::string& rootPath_y){ + size_t nameSize=file_x.size()-rootPath_x.size(); + if (nameSize != (file_y.size()-rootPath_y.size())) + return false; + return 0==memcmp(file_x.c_str()+rootPath_x.size(),file_y.c_str()+rootPath_y.size(),nameSize); +} + static void packSamePairList(std::vector& out_data,const std::vector& pairs){ size_t backPairNew=~(size_t)0; size_t backPairOld=~(size_t)0; @@ -262,6 +270,14 @@ struct CChecksumCombine:public CChecksum{ cmp_hash_value_t _combineHash; }; +static void _getExecuteList(std::vector& outExecuteList, + IDirDiffListener* listener,const std::vector& pathList){ + for (size_t i=0; iisExecuteFile(pathList[i]))) + outExecuteList.push_back(i); + } +} + void dir_diff(IDirDiffListener* listener,const TManifest& oldManifest, const TManifest& newManifest,const hpatch_TStreamOutput* outDiffStream, const hdiff_TCompress* compressPlugin,hpatch_TChecksum* checksumPlugin, @@ -285,10 +301,7 @@ void dir_diff(IDirDiffListener* listener,const TManifest& oldManifest, std::vector newRefIList; std::vector newExecuteList; //for linux etc - for (size_t newi=0; newiisExecuteFile(newList[newi]))) - newExecuteList.push_back(newi); - } + _getExecuteList(newExecuteList,listener,newList); const bool isCachedHashs=(checksumPlugin!=0)&&(checksumPlugin->checksumType()==cmp_hash_type); if (isCachedHashs) checkv(sizeof(cmp_hash_value_t)==checksumPlugin->checksumByteSize()); @@ -297,6 +310,22 @@ void dir_diff(IDirDiffListener* listener,const TManifest& oldManifest, getRefList(oldManifest.rootPath,newManifest.rootPath,oldList,newList, oldSizeList,newSizeList,dataSamePairList,oldRefIList,newRefIList, isCachedHashs,oldHashList,newHashList); + if (hdiffSets.isCheckNotEqual){ + bool isEq=(oldIsDir==newIsDir) + &&(oldList.size()==newList.size()) //same file count + &&(oldSizeList==newSizeList) + &&oldRefIList.empty()&&newRefIList.empty(); //same file datas; + //same names + for (size_t i=0;isEq&&(iisExecuteFile(oldfile)); + } + check(!isEq,"oldPath & newPath's all datas can't be equal"); + } std::vector newRefSizeList; CFileResHandleLimit resLimit(kMaxOpenFileNumber,oldRefIList.size()+newRefIList.size()); { diff --git a/dirDiffPatch/dir_diff/dir_diff.h b/dirDiffPatch/dir_diff/dir_diff.h index 641fe534..b5dc21c2 100644 --- a/dirDiffPatch/dir_diff/dir_diff.h +++ b/dirDiffPatch/dir_diff/dir_diff.h @@ -35,6 +35,7 @@ struct THDiffSets{ hpatch_BOOL isSingleCompressedDiff; //diff in mem hpatch_BOOL isUseBigCacheMatch; + hpatch_BOOL isCheckNotEqual; size_t matchScore; size_t patchStepMemSize; size_t matchBlockSize; diff --git a/hdiffz.cpp b/hdiffz.cpp index 04ad924b..a4a0c709 100644 --- a/hdiffz.cpp +++ b/hdiffz.cpp @@ -356,6 +356,9 @@ static void printUsage(){ " -D force run Directory diff between two files; DEFAULT (no -D) run \n" " directory diff need oldPath or newPath is directory.\n" #endif //_IS_NEED_DIR_DIFF_PATCH + " -neq\n" + " open check: if newPach & oldPach's all datas are equal, then return error; \n" + " DEFAULT not check equal.\n" " -d Diff only, do't run patch check, DEFAULT run patch check.\n" " -t Test only, run patch check, patch(oldPath,testDiffFile)==newPath ? \n" " -f Force overwrite, ignore write path already exists;\n" @@ -391,6 +394,7 @@ typedef enum THDiffResult { HDIFF_TEMPPATH_ERROR, HDIFF_DELETEPATH_ERROR, // 15 HDIFF_RENAMEPATH_ERROR, + HDIFF_OLD_NEW_SAME_ERROR,//adding begin v4.7.0 ; note: now not included dir_diff(), dir_diff thow an error & return DIRDIFF_DIFF_ERROR DIRDIFF_DIFF_ERROR=101, DIRDIFF_PATCH_ERROR, @@ -780,6 +784,7 @@ int hdiff_cmd_line(int argc, const char * argv[]){ diffSets.isDiffInMem =_kNULL_VALUE; diffSets.isSingleCompressedDiff =_kNULL_VALUE; diffSets.isUseBigCacheMatch =_kNULL_VALUE; + diffSets.isCheckNotEqual =_kNULL_VALUE; diffSets.matchBlockSize=_kNULL_SIZE; diffSets.threadNum=_THREAD_NUMBER_NULL; diffSets.threadNumSearch_s=_THREAD_NUMBER_NULL; @@ -978,12 +983,6 @@ int hdiff_cmd_line(int argc, const char * argv[]){ isSetChecksum=hpatch_TRUE; _options_check(_getOptChecksum(&checksumPlugin,ptype,"no"),"-C-?"); } break; - case 'n':{ - _options_check((kMaxOpenFileNumber==_kNULL_SIZE)&&(op[2]=='-'),"-n") - const char* pnum=op+3; - _options_check(kmg_to_size(pnum,strlen(pnum),&kMaxOpenFileNumber),"-n-?"); - _options_check((kMaxOpenFileNumber!=_kNULL_SIZE),"-n-?"); - } break; case 'g':{ if (op[2]=='#'){ //-g# const char* plist=op+3; @@ -1026,6 +1025,21 @@ int hdiff_cmd_line(int argc, const char * argv[]){ isForceRunDirDiff=hpatch_TRUE; //force run DirDiff } break; #endif + case 'n':{ + _options_check((op[2]!='\0'), "-n?"); +#if (_IS_NEED_DIR_DIFF_PATCH) + if (op[2]=='-'){ + _options_check((kMaxOpenFileNumber == _kNULL_SIZE), "-n-") + const char* pnum = op + 3; + _options_check(kmg_to_size(pnum, strlen(pnum), &kMaxOpenFileNumber), "-n-?"); + _options_check((kMaxOpenFileNumber != _kNULL_SIZE), "-n-?"); + }else +#endif + { + _options_check((diffSets.isCheckNotEqual==_kNULL_VALUE)&&(op[2]=='e')&&(op[3]=='q')&&(op[4]=='\0'),"-neq"); + diffSets.isCheckNotEqual=hpatch_TRUE; + } + } break; default: { _options_check(hpatch_FALSE,"-?"); } break; @@ -1051,6 +1065,8 @@ int hdiff_cmd_line(int argc, const char * argv[]){ if (isPrintFileInfo){ return hpatch_printFilesInfos((int)arg_values.size(),arg_values.data()); } + if (diffSets.isCheckNotEqual==_kNULL_VALUE) + diffSets.isCheckNotEqual=hpatch_FALSE; if (diffSets.isSingleCompressedDiff==_kNULL_VALUE) diffSets.isSingleCompressedDiff=hpatch_FALSE; #if (_IS_NEED_BSDIFF) @@ -1389,6 +1405,9 @@ static int hdiff_in_mem(const char* oldFileName,const char* newFileName,const ch printf("oldDataSize : %" PRIu64 "\nnewDataSize : %" PRIu64 "\n", (hpatch_StreamPos_t)oldMem.size(),(hpatch_StreamPos_t)newMem.size()); if (diffSets.isDoDiff){ + if (diffSets.isCheckNotEqual) + check((oldMem.size()!=newMem.size())||(0!=memcmp(oldMem.data(),newMem.data(),oldMem.size())), + HDIFF_OLD_NEW_SAME_ERROR,"oldFile & newFile's datas can't be equal"); check(hpatch_TFileStreamOutput_open(&diffData_out,outDiffFileName,hpatch_kNullStreamPos), HDIFF_OPENWRITE_ERROR,"open out diffFile"); hpatch_TFileStreamOutput_setRandomOut(&diffData_out,hpatch_TRUE); @@ -1539,6 +1558,8 @@ static int hdiff_by_stream(const char* oldFileName,const char* newFileName,const printf("oldDataSize : %" PRIu64 "\nnewDataSize : %" PRIu64 "\n", oldData.base.streamSize,newData.base.streamSize); if (diffSets.isDoDiff){ + if (diffSets.isCheckNotEqual) + check(!hdiff_streamDataIsEqual(&oldData.base,&newData.base),HDIFF_OLD_NEW_SAME_ERROR,"oldFile & newFile's datas can't be equal"); const hdiff_TMTSets_s mtsets={diffSets.threadNum,diffSets.threadNumSearch_s,false,false,false}; check(hpatch_TFileStreamOutput_open(&diffData_out,outDiffFileName,hpatch_kNullStreamPos), HDIFF_OPENWRITE_ERROR,"open out diffFile"); diff --git a/hpatchz.c b/hpatchz.c index 9c1824ad..bb1b4b67 100644 --- a/hpatchz.c +++ b/hpatchz.c @@ -415,8 +415,8 @@ int hpatch_cmd_line(int argc, const char * argv[]){ hpatch_BOOL isOutputHelp=_kNULL_VALUE; hpatch_BOOL isOutputVersion=_kNULL_VALUE; hpatch_BOOL isOldPathInputEmpty=_kNULL_VALUE; -#if (_IS_NEED_SFX) hpatch_BOOL isRunSFX=_kNULL_VALUE; +#if (_IS_NEED_SFX) const char* out_SFX=0; const char* selfExecuteFile=0; #endif @@ -432,10 +432,6 @@ int hpatch_cmd_line(int argc, const char * argv[]){ const char* arg_values[kMax_arg_values_size]={0}; int arg_values_size=0; int i; - if (argc<=1){ - printUsage(); - return HPATCH_OPTIONS_ERROR; - } for (i=1; i Date: Fri, 12 Jul 2024 13:16:26 +0800 Subject: [PATCH 4/4] update version & doc; --- CHANGELOG.md | 9 +++++++++ README.md | 11 ++++++++--- README_cn.md | 11 ++++++++--- hdiffz.cpp | 2 +- libHDiffPatch/HPatch/patch_types.h | 4 ++-- 5 files changed, 28 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b195323e..3cc6a4c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ full changelog at: https://github.com/sisong/HDiffPatch/commits +## [v4.7.0](https://github.com/sisong/HDiffPatch/tree/v4.7.0) - 2024-07-12 +### Added +* cmdline hdiffz support option "-BSD -SD", to create diffFile compatible with another BSDIFF format "ENDSLEY/BSDIFF43", https://github.com/mendsley/bsdiff ; patch support this format from v4.6.7 +* cmdline hdiffz support option "-neq"; if opened, hdiffz will refuse to created diffFile when oldData==newData. +### Fixed +* fixed SFX auto extract logic (SFX executable file is hpatchz file + diffFile) +SFX extract with default option `$selfExtractArchive -f ".\" -X ".\"` when diffFile created by directories; +if diffFile created by empty oldPath, then extract with default option `$selfExtractArchive -f "" -X ".\"`. + ## [v4.6.9](https://github.com/sisong/HDiffPatch/tree/v4.6.9) - 2023-12-01 ### Added * cmdline hdiffz & hpatchz support option "-info diffFile", print infos of diffFile; diff --git a/README.md b/README.md index f4b04885..9fa0041c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # [HDiffPatch] -[![release](https://img.shields.io/badge/release-v4.6.10-blue.svg)](https://github.com/sisong/HDiffPatch/releases) +[![release](https://img.shields.io/badge/release-v4.7.0-blue.svg)](https://github.com/sisong/HDiffPatch/releases) [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/sisong/HDiffPatch/blob/master/LICENSE) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg)](https://github.com/sisong/HDiffPatch/pulls) [![+issue Welcome](https://img.shields.io/github/issues-raw/sisong/HDiffPatch?color=green&label=%2Bissue%20welcome)](https://github.com/sisong/HDiffPatch/issues) @@ -122,6 +122,8 @@ options: stepSize>=(1024*4), DEFAULT -SD-256k, recommended 64k,2m etc... -BSD create diffFile compatible with bsdiff4, unsupport input directory(folder). + support run with -SD (not used stepSize), then create single compressed + diffFile compatible with endsley/bsdiff (https://github.com/mendsley/bsdiff). -VCD[-compressLevel[-dictSize]] create diffFile compatible with VCDIFF, unsupport input directory(folder). DEFAULT no compress, out format same as $open-vcdiff ... or $xdelta3 -S -e -n ... @@ -195,6 +197,9 @@ options: newManifestFile is created from newPath; -D force run Directory diff between two files; DEFAULT (no -D) run directory diff need oldPath or newPath is directory. + -neq + open check: if newPath & oldPath's all datas are equal, then return error; + DEFAULT not check equal. -d Diff only, do't run patch check, DEFAULT run patch check. -t Test only, run patch check, patch(oldPath,testDiffFile)==newPath ? -f Force overwrite, ignore write path already exists; @@ -215,7 +220,7 @@ uncompress usage: **hpatchz** [options] **"" diffFile outNewPath** print info: **hpatchz** -info **diffFile** create SFX: **hpatchz** [-X-exe#selfExecuteFile] **diffFile -X#outSelfExtractArchive** run SFX: **selfExtractArchive** [options] **oldPath -X outNewPath** -extract SFX: **selfExtractArchive** (same as: selfExtractArchive -f "" -X "./") +extract SFX: **selfExtractArchive** (same as: $selfExtractArchive -f {""|".\"} -X ".\") ``` if oldPath is empty input parameter "" options: @@ -305,7 +310,7 @@ options: * **create_lite_diff()** * **hpatch_lite_open()** * **hpatch_lite_patch()** -#### bsdiff wrapper API: +#### bsdiff4 & endsley/bsdiff wrapper API: * **create_bsdiff()** * **create_bsdiff_stream()** * **bspatch_with_cache()** diff --git a/README_cn.md b/README_cn.md index 8f39d56c..7b30b00b 100644 --- a/README_cn.md +++ b/README_cn.md @@ -1,5 +1,5 @@ # [HDiffPatch] -[![release](https://img.shields.io/badge/release-v4.6.10-blue.svg)](https://github.com/sisong/HDiffPatch/releases) +[![release](https://img.shields.io/badge/release-v4.7.0-blue.svg)](https://github.com/sisong/HDiffPatch/releases) [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/sisong/HDiffPatch/blob/master/LICENSE) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-blue.svg)](https://github.com/sisong/HDiffPatch/pulls) [![+issue Welcome](https://img.shields.io/github/issues-raw/sisong/HDiffPatch?color=green&label=%2Bissue%20welcome)](https://github.com/sisong/HDiffPatch/issues) @@ -122,6 +122,8 @@ $ git clone https://github.com/sisong/bzip2.git ../bzip2 压缩步长stepSize>=(1024*4), 默认为256k, 推荐64k,2m等。 -BSD 创建一个和bsdiff4兼容的补丁, 不支持参数为文件夹。 + 支持和-SD选项一起运行(不使用其stepSize), 创建单压缩流的补丁文件, + 兼容endsley/bsdiff格式 (https://github.com/mendsley/bsdiff)。 -VCD[-compressLevel[-dictSize]] 创建一个标准规范VCDIFF格式的补丁, 不支持参数为文件夹。 默认输出补丁不带压缩, 格式和 $open-vcdiff ... 或 $xdelta3 -S -e -n ... 命令输出的补丁格式兼容; @@ -191,6 +193,9 @@ $ git clone https://github.com/sisong/bzip2.git ../bzip2 设置newPath的清单文件newManifestFile; -D 强制执行文件夹间的diff, 即使输入的是2个文件; 从而为文件间的补丁添加校验功能。 默认情况下oldPath或newPath有一个是文件夹时才会执行文件夹间的diff。 + -neq + 打开检查: 如果newPath和oldPath的数据都相同,则返回错误; + 默认不执行该相等检查。 -d 只执行diff, 不要执行patch检查, 默认会执行patch检查. -t 只执行patch检查, 检查是否 patch(oldPath,testDiffFile)==newPath ? -f 强制文件写覆盖, 忽略输出的路径是否已经存在; @@ -213,7 +218,7 @@ $ git clone https://github.com/sisong/bzip2.git ../bzip2 (将目标平台的hpatchz可执行文件和补丁包文件合并成一个可执行文件, 称作自释放包SFX) 执行一个自释放包: **selfExtractArchive** [options] **oldPath -X outNewPath** (利用自释放包来打补丁,将包中自带的补丁数据应用到oldPath上, 合成outNewPath) -执行一个自解压包: **selfExtractArchive** (等价于: selfExtractArchive -f "" -X "./") +执行一个自解压包: **selfExtractArchive** (等价于:$selfExtractArchive -f {""|".\"} -X "./") ``` oldPath可以为空, 输入参数为 "" 选项: @@ -301,7 +306,7 @@ $ git clone https://github.com/sisong/bzip2.git ../bzip2 * **create_lite_diff()** * **hpatch_lite_open()** * **hpatch_lite_patch()** -#### bsdiff 兼容包装 API: +#### bsdiff4 和 endsley/bsdiff 兼容包装 API: * **create_bsdiff()** * **create_bsdiff_stream()** * **bspatch_with_cache()** diff --git a/hdiffz.cpp b/hdiffz.cpp index a4a0c709..041a2268 100644 --- a/hdiffz.cpp +++ b/hdiffz.cpp @@ -357,7 +357,7 @@ static void printUsage(){ " directory diff need oldPath or newPath is directory.\n" #endif //_IS_NEED_DIR_DIFF_PATCH " -neq\n" - " open check: if newPach & oldPach's all datas are equal, then return error; \n" + " open check: if newPath & oldPath's all datas are equal, then return error; \n" " DEFAULT not check equal.\n" " -d Diff only, do't run patch check, DEFAULT run patch check.\n" " -t Test only, run patch check, patch(oldPath,testDiffFile)==newPath ? \n" diff --git a/libHDiffPatch/HPatch/patch_types.h b/libHDiffPatch/HPatch/patch_types.h index 40e1d933..59caa9cb 100644 --- a/libHDiffPatch/HPatch/patch_types.h +++ b/libHDiffPatch/HPatch/patch_types.h @@ -37,8 +37,8 @@ extern "C" { #endif #define HDIFFPATCH_VERSION_MAJOR 4 -#define HDIFFPATCH_VERSION_MINOR 6 -#define HDIFFPATCH_VERSION_RELEASE 10 +#define HDIFFPATCH_VERSION_MINOR 7 +#define HDIFFPATCH_VERSION_RELEASE 0 #define _HDIFFPATCH_VERSION HDIFFPATCH_VERSION_MAJOR.HDIFFPATCH_VERSION_MINOR.HDIFFPATCH_VERSION_RELEASE #define _HDIFFPATCH_QUOTE(str) #str