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 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
## most of this is copied from VLC install script
## , with bugfixes and decorated with some additional comments for better understanding
!ifndef FOLDERLIST_EXE
!define FOLDERLIST_EXE FolderList.exe
!endif
;;;;;;;;;;;;;;;
; 4. Logging ;
;;;;;;;;;;;;;;;
Var UninstallLog # handle to a log file
!macro OpenUninstallLog
FileOpen $UninstallLog "$INSTDIR\uninstall.log" a
FileSeek $UninstallLog 0 END
!macroend
!macro CloseUninstallLog
FileClose $UninstallLog
SetFileAttributes "$INSTDIR\uninstall.log" HIDDEN
!macroend
;;;;;;;;;;;;;;;;;;;;
; 5. Installations ;
;;;;;;;;;;;;;;;;;;;;
!macro InstallFile FILEREGEX
# do the normal job
File "${FILEREGEX}"
## add files to uninstall.log
#strip source path (retain filename only)
push $R0
${GetFileName} "${FILEREGEX}" $R0
!define Index 'Line${__LINE__}'
# search for filename in target path
FindFirst $0 $1 "$OUTDIR\$R0"
StrCmp $0 "" "${Index}-End"
"${Index}-Loop:"
StrCmp $1 "" "${Index}-End"
FileWrite $UninstallLog "$OUTDIR\$1$\r$\n"
FindNext $0 $1
Goto "${Index}-Loop"
"${Index}-End:"
!undef Index
pop $R0
!macroend
!macro InstallFolder FOLDER EXCLUDEREGEX
#old: File /r "${FOLDER}"
!system "${FOLDERLIST_EXE} /r $\"${FOLDER} $\" $\"${EXCLUDEREGEX}$\""
!include "${FOLDERLIST_EXE}.txt"
Push "$OUTDIR"
Call InstallFolderInternal
!macroend
## $9 is the complete folder name
Function InstallFolderInternal
Pop $9
!define Index 'Line${__LINE__}'
FindFirst $0 $1 "$9\*"
StrCmp $0 "" "${Index}-End"
"${Index}-Loop:"
StrCmp $1 "" "${Index}-End"
StrCmp $1 "." "${Index}-Next"
StrCmp $1 ".." "${Index}-Next"
IfFileExists "$9\$1\*" 0 "${Index}-Write"
Push $0
Push $9
Push "$9\$1"
Call InstallFolderInternal
Pop $9
Pop $0
Goto "${Index}-Next"
"${Index}-Write:"
FileWrite $UninstallLog "$9\$1$\r$\n"
"${Index}-Next:"
FindNext $0 $1
Goto "${Index}-Loop"
"${Index}-End:"
!undef Index
FunctionEnd
; TrimNewlines (copied from NSIS documentation)
; input, top of stack (e.g. whatever$\r$\n)
; output, top of stack (replaces, with e.g. whatever)
; modifies no other variables.
Function un.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__}'
; 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 un.RemoveEmptyDirs
; Pop $9
; Pop $1
; Pop $0
; "${Index}-Remove:"
; RMDir "$INSTDIR$9$1"
; "${Index}-Next:"
; FindNext $0 $1
; Goto "${Index}-Loop"
; "${Index}-End:"
; FindClose $0
; !undef Index
; FunctionEnd
|