Add a detection on non empty folder before installing the application.
This commit is contained in:
parent
df6f39addc
commit
ad4e675f66
1 changed files with 40 additions and 3 deletions
|
|
@ -504,8 +504,46 @@ Function ConditionalAddToRegisty
|
||||||
ConditionalAddToRegisty_EmptyString:
|
ConditionalAddToRegisty_EmptyString:
|
||||||
FunctionEnd
|
FunctionEnd
|
||||||
|
|
||||||
|
|
||||||
|
Function isEmptyDir
|
||||||
|
# Stack -> # Stack: <directory>
|
||||||
|
Exch $0 # Stack: $0
|
||||||
|
Push $1 # Stack: $1, $0
|
||||||
|
FindFirst $0 $1 "$0\*.*"
|
||||||
|
strcmp $1 "." 0 _notempty
|
||||||
|
FindNext $0 $1
|
||||||
|
strcmp $1 ".." 0 _notempty
|
||||||
|
ClearErrors
|
||||||
|
FindNext $0 $1
|
||||||
|
IfErrors 0 _notempty
|
||||||
|
FindClose $0
|
||||||
|
Pop $1 # Stack: $0
|
||||||
|
StrCpy $0 1
|
||||||
|
Exch $0 # Stack: 1 (true)
|
||||||
|
goto _end
|
||||||
|
_notempty:
|
||||||
|
FindClose $0
|
||||||
|
ClearErrors
|
||||||
|
Pop $1 # Stack: $0
|
||||||
|
StrCpy $0 0
|
||||||
|
Exch $0 # Stack: 0 (false)
|
||||||
|
_end:
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
|
Function InstDirValidation
|
||||||
|
IfFileExists $INSTDIR\* 0 isEmpty
|
||||||
|
Push "$INSTDIR"
|
||||||
|
Call isEmptyDir
|
||||||
|
Pop $0
|
||||||
|
StrCmp $0 0 0 isEmpty
|
||||||
|
MessageBox MB_OK "$INSTDIR is not empty. Please delete it and retry."
|
||||||
|
Abort
|
||||||
|
isEmpty:
|
||||||
|
FunctionEnd
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
|
|
||||||
|
|
||||||
!ifdef CPACK_USES_DOWNLOAD
|
!ifdef CPACK_USES_DOWNLOAD
|
||||||
Function DownloadFile
|
Function DownloadFile
|
||||||
IfFileExists $INSTDIR\* +2
|
IfFileExists $INSTDIR\* +2
|
||||||
|
|
@ -555,6 +593,8 @@ FunctionEnd
|
||||||
!endif
|
!endif
|
||||||
|
|
||||||
Page custom InstallOptionsPage
|
Page custom InstallOptionsPage
|
||||||
|
|
||||||
|
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE InstDirValidation
|
||||||
!insertmacro MUI_PAGE_DIRECTORY
|
!insertmacro MUI_PAGE_DIRECTORY
|
||||||
|
|
||||||
;Start Menu Folder Page Configuration
|
;Start Menu Folder Page Configuration
|
||||||
|
|
@ -911,9 +951,6 @@ SectionEnd
|
||||||
; "Program Files" for AllUsers, "My Documents" for JustMe...
|
; "Program Files" for AllUsers, "My Documents" for JustMe...
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Function .onInit
|
Function .onInit
|
||||||
ClearErrors
|
ClearErrors
|
||||||
ExecWait '"cmd" /C ""%SystemRoot%\System32\tasklist" /NH /FI "IMAGENAME eq @CPACK_NSIS_MUI_FINISHPAGE_RUN@" | "%SystemRoot%\System32\find" /I /C "@CPACK_NSIS_MUI_FINISHPAGE_RUN@""' $0
|
ExecWait '"cmd" /C ""%SystemRoot%\System32\tasklist" /NH /FI "IMAGENAME eq @CPACK_NSIS_MUI_FINISHPAGE_RUN@" | "%SystemRoot%\System32\find" /I /C "@CPACK_NSIS_MUI_FINISHPAGE_RUN@""' $0
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue