fixed bug #1829540 - VPatchFile macro does not handle spaces or absolute paths

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5366 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2007-11-10 16:51:39 +00:00
parent feb5dca48e
commit 0b8eb1365e

View file

@ -4,19 +4,46 @@
; Library with macro for use with VPatch (DLL version) in NSIS 2.0.5+ ; Library with macro for use with VPatch (DLL version) in NSIS 2.0.5+
; Created by Koen van de Sande ; Created by Koen van de Sande
!include LogicLib.nsh
!macro VPatchFile PATCHDATA SOURCEFILE TEMPFILE !macro VPatchFile PATCHDATA SOURCEFILE TEMPFILE
Push $1
Push $2
Push $3
Push $4
Push ${PATCHDATA}
Push ${SOURCEFILE}
Push ${TEMPFILE}
Pop $2 # temp file
Pop $3 # source file
Pop $4 # patch data
InitPluginsDir InitPluginsDir
File /oname=$PLUGINSDIR\${PATCHDATA} ${PATCHDATA} GetTempFileName $1 $PLUGINSDIR
vpatch::vpatchfile "$PLUGINSDIR\${PATCHDATA}" "${SOURCEFILE}" "${TEMPFILE}" File /oname=$1 $4
Pop $1
DetailPrint $1 vpatch::vpatchfile $1 $3 $2
StrCpy $1 $1 2 Pop $4
StrCmp $1 "OK" ok_${SOURCEFILE} DetailPrint $4
StrCpy $4 $4 2
${Unless} $4 == "OK"
SetErrors SetErrors
ok_${SOURCEFILE}: ${EndIf}
IfFileExists "${TEMPFILE}" +1 end_${SOURCEFILE}
Delete "${SOURCEFILE}" ${If} ${FileExists} $2
Rename /REBOOTOK "${TEMPFILE}" "${SOURCEFILE}" Delete $3
end_${SOURCEFILE}: Rename /REBOOTOK $2 $3
Delete "$PLUGINSDIR\${PATCHDATA}" ${EndIf}
Delete $1
Pop $4
Pop $3
Pop $2
Pop $1
!macroend !macroend