Commit fe8b55e6 authored by Marvin Scholz's avatar Marvin Scholz Committed by Jean-Baptiste Kempf

NSIS: Remove old files before new install

Fix #19253

(cherry picked from commit 2b6c36dd)
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 4e1f9125
......@@ -214,6 +214,27 @@ Function un.TrimNewlines
Exch $R0
FunctionEnd
Function TrimNewlines
Exch $R0
Push $R1
Push $R2
StrCpy $R1 0
loop:
IntOp $R1 $R1 - 1
StrCpy $R2 $R0 1 $R1
StrCmp $R2 "$\r" loop
StrCmp $R2 "$\n" loop
IntOp $R1 $R1 + 1
IntCmp $R1 0 no_trim_needed
StrCpy $R0 $R0 $R1
no_trim_needed:
Pop $R2
Pop $R1
Exch $R0
FunctionEnd
Function un.RemoveEmptyDirs
Pop $9
!define Index 'Line${__LINE__}'
......@@ -240,6 +261,32 @@ Function un.RemoveEmptyDirs
!undef Index
FunctionEnd
Function RemoveEmptyDirs
Pop $9
!define Index 'Line${__LINE__}'
FindFirst $0 $1 "$INSTDIR$9*"
StrCmp $0 "" "${Index}-End"
"${Index}-Loop:"
StrCmp $1 "" "${Index}-End"
StrCmp $1 "." "${Index}-Next"
StrCmp $1 ".." "${Index}-Next"
Push $0
Push $1
Push $9
Push "$9$1\"
Call RemoveEmptyDirs
Pop $9
Pop $1
Pop $0
RMDir "$INSTDIR$9$1"
"${Index}-Next:"
FindNext $0 $1
Goto "${Index}-Loop"
"${Index}-End:"
FindClose $0
!undef Index
FunctionEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Check if VLC is running and kill it if necessary ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
......
......@@ -238,6 +238,26 @@ ${MementoSection} "$(Name_Section01)" SEC01
DetailPrint "$(Detail_CheckProcesses)"
Call CheckRunningProcesses
; Remove previous version first, if this is update
${If} $ReinstallType == "1"
FileOpen $UninstallLog "$INSTDIR\uninstall.log" r
UninstallLoop:
ClearErrors
FileRead $UninstallLog $R0
IfErrors UninstallEnd
Push $R0
Call TrimNewLines
Pop $R0
Delete "$INSTDIR\$R0"
Goto UninstallLoop
UninstallEnd:
FileClose $UninstallLog
Delete "$INSTDIR\uninstall.log"
Delete "$INSTDIR\uninstall.exe"
Push "\"
Call RemoveEmptyDirs
${EndIf}
!insertmacro OpenUninstallLog
; VLC.exe, libvlc.dll
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment