From 53f3739c7ff34e33358f5837ec0348e87334dada Mon Sep 17 00:00:00 2001 From: sisong Date: Thu, 11 Jul 2024 14:51:41 +0800 Subject: [PATCH] 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){