From 7f58d2e6b9ca2c5fa5e1199e38aecc5f16f0c37f Mon Sep 17 00:00:00 2001 From: Mark Hessling Date: Sun, 24 Aug 2003 09:50:28 +0000 Subject: [PATCH] Support for WIn9x adding dir into PATH if not already there --- common/path.nsh | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/common/path.nsh b/common/path.nsh index 140ee04f..a67e14cd 100644 --- a/common/path.nsh +++ b/common/path.nsh @@ -19,12 +19,35 @@ Function AddToPath Pop $1 StrCmp $1 1 AddToPath_NT ; Not on NT - StrCpy $1 $WINDIR 2 - FileOpen $1 "$1\autoexec.bat" a + ; $0 has the directory to add + StrCpy $1 $WINDIR 2 ;get the drive letter and colon into $1 + GetFullPathName /SHORT $6 $0 + StrCpy $6 "SET PATH=%PATH%;$6" ; $6 has the string we would have written when installing (except for leading CRLF) + ; Determine if the dir entry is already there (and written by us) + FileOpen $5 "$1\autoexec.bat" r ; $5 has autoexec.bat handle + + InPath_dosLoop: + FileRead $5 $3 ; $3 has 1 line from autoexec.bat + StrCmp $3 "$6$\r$\n" InPath_dosLoopFound ; get out if we found our string + StrCmp $3 "$6$\n" InPath_dosLoopFound ; get out if we found our string + StrCmp $3 "$6" InPath_dosLoopFound ; get out if we found our string + StrCmp $3 "" InPath_dosLoopEnd + Goto InPath_dosLoop + + ; we found our string, so dir is already in PATH, don't do any more + InPath_dosLoopFound: + FileClose $5 + Goto AddToPath_done + + InPath_dosLoopEnd: + FileClose $5 + + FileOpen $1 "$1\autoexec.bat" a ; $1 now has autoexec.bat handle FileSeek $1 0 END GetFullPathName /SHORT $0 $0 FileWrite $1 "$\r$\nSET PATH=%PATH%;$0$\r$\n" FileClose $1 + SetRebootFlag true Goto AddToPath_done AddToPath_NT: @@ -34,7 +57,7 @@ Function AddToPath Push $0 ; push the new PATH item onto the stack Call StrStr ; Find $0 in $1 Pop $2 ; pos of the new PATH item in current PATH (-1 if not found) - IntCmp $2 -1 AddToPath_NTdoit + IntCmp $2 -1 AddToPath_NTdoIt Goto AddToPath_done AddToPath_NTdoIt: