Skip to content

Commit 15a03c1

Browse files
committed
Delete 'MTA San Andreas All' in ProgramData in uninstaller
Removes 'MTA San Andreas All' directory if 'Common' is the only directory left. This only affects 'C:\ProgramData\MTA San Andreas All'.
1 parent 3811d8c commit 15a03c1

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Shared/installer/NSIS dirs/Include/Utils.nsh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,30 @@
4343
!define RemoveRegistryGroupWithSingleKey `!insertmacro _RemoveRegistryGroupWithSingleKey`
4444

4545

46+
;----------------------------------------
47+
; Removes a directory if there is only one child directory with a particular name present.
48+
; IN PARENT_DIR: Path to the parent directory
49+
; IN DIRNAME: Name of the child directory to check against
50+
;----------------------------------------
51+
!macro _RmDirWithSingleChildDir PARENT_DIR DIRNAME
52+
Push $0
53+
Push $1
54+
FindFirst $0 $1 "${PARENT_DIR}\*"
55+
StrCmp $1 "" +4 ; [Delete] Either empty or it only contains our file
56+
StrCmp $1 "." +5 ; [Next] Current directory
57+
StrCmp $1 ".." +4 ; [Next] Parent directory
58+
StrCmp $1 "${DIRNAME}" +3 +5 ; [Next] If matching, [Break] otherwise
59+
RmDir /r "${PARENT_DIR}"
60+
Goto +3 ; [Break]
61+
FindNext $0 $1
62+
Goto -7 ; [Continue]
63+
FindClose $0
64+
Pop $1
65+
Pop $0
66+
!macroend
67+
!define RmDirWithSingleChildDir `!insertmacro _RmDirWithSingleChildDir`
68+
69+
4670
;----------------------------------------
4771
; In: FILENAME = filename
4872
; Out: MAJOR.MINOR.RELEASE.BUILD

Shared/installer/nightly.nsi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,8 @@ Section Uninstall
11361136
Delete "$INSTDIR\MTA\*.bin"
11371137

11381138
RmDir /r "$APPDATA\MTA San Andreas All\${0.0}"
1139-
; TODO if $APPDATA\MTA San Andreas All\Common is the only one left, delete it
1139+
; Delete "$APPDATA\MTA San Andreas All" if "Common" is the only directory in it.
1140+
${RmDirWithSingleChildDir} "$APPDATA\MTA San Andreas All" "Common"
11401141

11411142
DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
11421143
DeleteRegKey HKLM "${PRODUCT_DIR_REGKEY}"

0 commit comments

Comments
 (0)