Debian Codegraph @

Contrib/VPatch/example.nsi

raw
1 ;VPatch example
2 ;Written by Joost Verburg
3
4 ;--------------------------------
5
6 ; The name of the installer
7 Name "VPatch Test"
8
9 ; The file to write
10 OutFile "vpatchtest.exe"
11
12 ; The default installation directory
13 InstallDir "$PROGRAMFILES\VPatch Test"
14
15 ; The text to prompt the user to enter a directory
16 DirText "Choose a folder in which to install the VPatch Test!"
17
18 ; Show details
19 ShowInstDetails show
20
21 ;--------------------------------
22 ; The normal way to use VPatch
23 ;--------------------------------
24 !include "VPatchLib.nsh"
25
26 Section "Update file"
27 ; Set output path to the installation directory
28 SetOutPath $INSTDIR
29
30 ; Extract the old file under name 'updatefile.txt'
31 File /oname=updatefile.txt oldfile.txt
32
33 ; Update the file - it will be replaced with the new version
34 DetailPrint "Updating updatefile.txt using patch..."
35 !insertmacro VPatchFile "patch.pat" "$INSTDIR\updatefile.txt" "$INSTDIR\temporaryfile.txt"
36
37 SectionEnd
38
39 ;-------------------------------
40 ; The hard way to use VPatch
41 ;-------------------------------
42 Section "New version in separate file"
43
44 ; Set output path to the installation directory
45 SetOutPath $INSTDIR
46
47 ; Extract the old file
48 File oldfile.txt
49
50 ; Extract the patch to the plug-ins folder (temporary)
51 InitPluginsDir
52 File /oname=$PLUGINSDIR\patch.pat patch.pat
53
54 ; Update the old file to the new file using the patch
55 DetailPrint "Updating oldfile.txt using patch to newfile.txt..."
56 vpatch::vpatchfile "$PLUGINSDIR\patch.pat" "$INSTDIR\oldfile.txt" "$INSTDIR\newfile.txt"
57
58 ; Show result
59 Pop $R0
60 DetailPrint "Result: $R0"
61
62 SectionEnd