Skip to content

Commit

Permalink
when SFX run with default options, now support oldPath is empty or cu…
Browse files Browse the repository at this point in the history
…rrent directory(before only empty);

close #387
  • Loading branch information
housisong committed Jul 11, 2024
1 parent 914c6db commit 53f3739
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
6 changes: 0 additions & 6 deletions builds/xcode/hpatchz.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -363,23 +363,17 @@
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;
};
D6553CBE165FA1A9009D4C44 /* Release */ = {
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;
};
Expand Down
33 changes: 19 additions & 14 deletions hpatchz.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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"
Expand Down Expand Up @@ -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)
Expand All @@ -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];
Expand All @@ -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),
Expand All @@ -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){
Expand Down

0 comments on commit 53f3739

Please sign in to comment.