Skip to content

Commit 939bb67

Browse files
committed
un7z operate on empty directory
1 parent 467e5a0 commit 939bb67

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

SfxSetup.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
399399
PrintErrorMessage("un7z.exe file [extractDir]");
400400
return 1;
401401
}
402-
if ((!PathFileExists(wargv[1])) || (PathIsDirectoryW(wargv[1])))
402+
if ((!DoesFileOrDirExist(wargv[1])) || (PathIsDirectoryW(wargv[1])))
403403
{
404404
PrintErrorMessage("file is not exists");
405405
return 1;
@@ -409,9 +409,16 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
409409
{
410410
GetFullPathNameW(wargv[2], MAX_PATH * 3 + 2, path, NULL);
411411
if (!PathIsDirectoryW(path))
412+
{
412413
if (SHCreateDirectoryExW(NULL, path, NULL) != ERROR_SUCCESS)
413414
{
414-
PrintErrorMessage("cannot create extraction directory");
415+
PrintErrorMessage("cannot create target");
416+
return 1;
417+
}
418+
}
419+
if (!PathIsDirectoryEmptyW(path))
420+
{
421+
PrintErrorMessage("target not empy");
415422
return 1;
416423
}
417424
}
@@ -616,7 +623,6 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
616623
executeFileIndex = i;
617624
useShellExecute = extPrice;
618625
}
619-
620626
if (DoesFileOrDirExist(path))
621627
{
622628
errorMessage = "Duplicate file";

basebin/7z.sfx

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)