File: miniz_test.nsi

package info (click to toggle)
win32-loader 0.10.6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 1,868 kB
  • sloc: ansic: 2,492; sh: 706; asm: 344; makefile: 338
file content (100 lines) | stat: -rw-r--r-- 2,275 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
; Licensed under the zlib/libpng license (same as NSIS)

; miniz test runner
; Run installer with the following arguments
;  /S /IN=<file> /OUT=<gzipfile> /RESULT=<result file>
; and for the uninstaller append the argument below:
; _?=<directory containing uninstaller>
Unicode True
Name miniz
RequestExecutionLevel user

!define UNFUNC "un."

!define CPIO_GZ_EXT ".cpio.gz"
!define CPIO_GZ_LEN 8

!include FileFunc.nsh

!insertmacro GetParameters
!insertmacro GetOptions

!include include\miniz.nsh

; Pages
Page InstFiles
UninstPage InstFiles

Var Arguments

!macro Run UN
!searchreplace INIT_FUNC "${UN}.onInit" ".." "."
Function ${INIT_FUNC}
  InitPluginsDir
  ${GetParameters} $Arguments
  ClearErrors
  SetOutPath "$EXEDIR"
FunctionEnd

${MINIZ_FUNCINC} "${UN}" CPIO_GZ_Open
${MINIZ_FUNCINC} "${UN}" CPIO_GZ_Write
${MINIZ_FUNCINC} "${UN}" CPIO_GZ_Close

${MINIZ_FUNCINC} "${UN}" GZip

Function ${UN}${__MACRO__}
  StrCpy $0 ${ERROR_WRITE_FAULT}
  ${GetOptions} $Arguments "/IN=" $1
  ${GetOptions} $Arguments "/OUT=" $2
  ${GetOptions} $Arguments "/RESULT=" $3

  FileOpen $4 "$3" w
  ${IfNot} ${Errors}
    StrCpy $7 $2 ${CPIO_GZ_LEN} -${CPIO_GZ_LEN}
    ${If} $7 != ${CPIO_GZ_EXT}
      FileOpen $5 "$1" r
      ${IfNot} ${Errors}
        FileOpen $6 "$2" w
        ${IfNot} ${Errors}
          !insertmacro MINIZ_GZip_Call "${UN}" $5 $6 $0
          FileClose $6
        ${EndIf}
        FileClose $5
      ${Else}
        StrCpy $0 ${ERROR_FILE_NOT_FOUND}
      ${EndIf}
    ${Else}
      FileOpen $5 "$2" w
      ${IfNot} ${Errors}
        !insertmacro MINIZ_CPIO_GZ_Open_Call "${UN}" $5 $6
        ${If} $6 P<> 0
          !insertmacro MINIZ_CPIO_GZ_Write_Call "${UN}" $6 $1 $0
          ${If} $0 == 0
            !insertmacro MINIZ_CPIO_GZ_Write_Call "${UN}" $6 "" $0
          ${EndIf}
          !insertmacro MINIZ_CPIO_GZ_Close_Call "${UN}" $6 $6
	  ${If} $0 == 0
          ${AndIf} $6 != 0
            StrCpy $0 $6
          ${EndIf}
        ${EndIf}
        FileClose $5
      ${EndIf}
    ${EndIf}
    FileWrite $4 "$0$\n"
    FileClose $4
  ${EndIf}
FunctionEnd
!macroend

!insertmacro Run ""
!insertmacro Run ${UNFUNC}

Section "Install"
  Call Run
  WriteUninstaller "$OUTDIR\uninstall.exe"
SectionEnd

Section "Uninstall"
  Call ${UNFUNC}Run
SectionEnd