Skip to content

Commit fc8cc5d

Browse files
committed
Relocating sources
1 parent ab9df18 commit fc8cc5d

7,802 files changed

Lines changed: 2443277 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/PyQt-gpl-5.4/AddToPath.nsh

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
;----------------------------------------
2+
; based upon a script of "Written by KiCHiK 2003-01-18 05:57:02"
3+
;----------------------------------------
4+
!verbose 3
5+
!include "WinMessages.NSH"
6+
!verbose 4
7+
;----------------------------------------------------
8+
!define NT_current_env 'HKCU "Environment"'
9+
!define NT_all_env 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"'
10+
;====================================================
11+
; IsNT - Returns 1 if the current system is NT, 0
12+
; otherwise.
13+
; Output: head of the stack
14+
;====================================================
15+
!macro IsNT UN
16+
Function ${UN}IsNT
17+
Push $0
18+
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
19+
StrCmp $0 "" 0 IsNT_yes
20+
; we are not NT.
21+
Pop $0
22+
Push 0
23+
Return
24+
25+
IsNT_yes:
26+
; NT!!!
27+
Pop $0
28+
Push 1
29+
FunctionEnd
30+
!macroend
31+
!insertmacro IsNT ""
32+
!insertmacro IsNT "un."
33+
;====================================================
34+
; AddToPath - Adds the given dir to the search path.
35+
; Input - head of the stack
36+
; Note - Win9x systems requires reboot
37+
;====================================================
38+
Function AddToPath
39+
Exch $0
40+
Push $1
41+
Push $2
42+
43+
Call IsNT
44+
Pop $1
45+
StrCmp $1 1 AddToPath_NT
46+
; Not on NT
47+
StrCpy $1 $WINDIR 2
48+
FileOpen $1 "$1\autoexec.bat" a
49+
FileSeek $1 0 END
50+
GetFullPathName /SHORT $0 $0
51+
FileWrite $1 "$\r$\nSET PATH=$0;%PATH%$\r$\n"
52+
FileClose $1
53+
Goto AddToPath_done
54+
55+
AddToPath_NT:
56+
Push $4
57+
; Try to set PATH for all.
58+
StrCpy $4 "all"
59+
60+
AddToPath_NT_selection_done:
61+
StrCmp $4 "current" read_path_NT_current
62+
ReadRegStr $1 ${NT_all_env} "PATH"
63+
Goto read_path_NT_resume
64+
read_path_NT_current:
65+
ReadRegStr $1 ${NT_current_env} "PATH"
66+
read_path_NT_resume:
67+
StrCpy $2 $0
68+
StrCmp $1 "" AddToPath_NTdoIt
69+
StrCpy $2 "$0;$1"
70+
AddToPath_NTdoIt:
71+
StrCmp $4 "current" write_path_NT_current
72+
ClearErrors
73+
WriteRegExpandStr ${NT_all_env} "PATH" $2
74+
IfErrors 0 write_path_NT_resume
75+
; Try again for the current user.
76+
StrCpy $4 "current"
77+
Goto AddToPath_NT_selection_done
78+
write_path_NT_current:
79+
ClearErrors
80+
WriteRegExpandStr ${NT_current_env} "PATH" $2
81+
IfErrors 0 write_path_NT_resume
82+
MessageBox MB_OK|MB_ICONINFORMATION "PATH could not be updated for all users or the current user."
83+
Goto write_path_NT_failed
84+
write_path_NT_resume:
85+
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
86+
DetailPrint "added path for user ($4), $0"
87+
write_path_NT_failed:
88+
89+
Pop $4
90+
AddToPath_done:
91+
Pop $2
92+
Pop $1
93+
Pop $0
94+
FunctionEnd
95+
96+
;====================================================
97+
; RemoveFromPath - Remove a given dir from the path
98+
; Input: head of the stack
99+
;====================================================
100+
Function un.RemoveFromPath
101+
Exch $0
102+
Push $1
103+
Push $2
104+
Push $3
105+
Push $4
106+
Push $5
107+
108+
Call un.IsNT
109+
Pop $1
110+
StrCmp $1 1 unRemoveFromPath_NT
111+
; Not on NT
112+
StrCpy $1 $WINDIR 2
113+
FileOpen $1 "$1\autoexec.bat" r
114+
GetTempFileName $4
115+
FileOpen $2 $4 w
116+
GetFullPathName /SHORT $0 $0
117+
StrCpy $0 "SET PATH=%PATH%;$0"
118+
SetRebootFlag true
119+
Goto unRemoveFromPath_dosLoop
120+
121+
unRemoveFromPath_dosLoop:
122+
FileRead $1 $3
123+
StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoop
124+
StrCmp $3 "$0$\n" unRemoveFromPath_dosLoop
125+
StrCmp $3 "$0" unRemoveFromPath_dosLoop
126+
StrCmp $3 "" unRemoveFromPath_dosLoopEnd
127+
FileWrite $2 $3
128+
Goto unRemoveFromPath_dosLoop
129+
130+
unRemoveFromPath_dosLoopEnd:
131+
FileClose $2
132+
FileClose $1
133+
StrCpy $1 $WINDIR 2
134+
Delete "$1\autoexec.bat"
135+
CopyFiles /SILENT $4 "$1\autoexec.bat"
136+
Delete $4
137+
Goto unRemoveFromPath_done
138+
139+
unRemoveFromPath_NT:
140+
StrLen $2 $0
141+
; Try to unset PATH for all.
142+
StrCpy $4 "all"
143+
ReadRegStr $1 ${NT_all_env} "PATH"
144+
145+
unRemoveFromPath_find:
146+
Push $1
147+
Push $0
148+
Call un.StrStr ; Find $0 in $1
149+
Pop $5 ; pos of our dir
150+
IntCmp $5 -1 unRemoveFromPath_next
151+
; else, it is in path
152+
StrCpy $3 $1 $5 ; $3 now has the part of the path before our dir
153+
IntOp $2 $2 + $5 ; $2 now contains the pos after our dir in the path (';')
154+
IntOp $2 $2 + 1 ; $2 now containts the pos after our dir and the semicolon.
155+
StrLen $5 $1
156+
StrCpy $1 $1 $5 $2
157+
StrCpy $3 "$3$1"
158+
159+
StrCmp $4 "current" un_write_path_NT_current
160+
WriteRegExpandStr ${NT_all_env} "PATH" $3
161+
Goto unRemoveFromPath_next
162+
un_write_path_NT_current:
163+
WriteRegExpandStr ${NT_current_env} "PATH" $3
164+
unRemoveFromPath_next:
165+
StrCmp $4 "current" unRemoveFromPath_done
166+
; Go round again for the current user.
167+
StrCpy $4 "current"
168+
ReadRegStr $1 ${NT_current_env} "PATH"
169+
Goto unRemoveFromPath_find
170+
unRemoveFromPath_done:
171+
SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
172+
Pop $5
173+
Pop $4
174+
Pop $3
175+
Pop $2
176+
Pop $1
177+
Pop $0
178+
FunctionEnd
179+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
180+
; Uninstall sutff
181+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
182+
183+
184+
;====================================================
185+
; StrStr - Finds a given string in another given string.
186+
; Returns -1 if not found and the pos if found.
187+
; Input: head of the stack - string to find
188+
; second in the stack - string to find in
189+
; Output: head of the stack
190+
;====================================================
191+
Function un.StrStr
192+
Push $0
193+
Exch
194+
Pop $0 ; $0 now have the string to find
195+
Push $1
196+
Exch 2
197+
Pop $1 ; $1 now have the string to find in
198+
Exch
199+
Push $2
200+
Push $3
201+
Push $4
202+
Push $5
203+
204+
StrCpy $2 -1
205+
StrLen $3 $0
206+
StrLen $4 $1
207+
IntOp $4 $4 - $3
208+
209+
unStrStr_loop:
210+
IntOp $2 $2 + 1
211+
IntCmp $2 $4 0 0 unStrStrReturn_notFound
212+
StrCpy $5 $1 $3 $2
213+
StrCmp $5 $0 unStrStr_done unStrStr_loop
214+
215+
unStrStrReturn_notFound:
216+
StrCpy $2 -1
217+
218+
unStrStr_done:
219+
Pop $5
220+
Pop $4
221+
Pop $3
222+
Exch $2
223+
Exch 2
224+
Pop $0
225+
Pop $1
226+
FunctionEnd
227+
;====================================================

0 commit comments

Comments
 (0)