From 57ea06261310a73dfc0eb87ab93cd13fb403ca31 Mon Sep 17 00:00:00 2001 From: kichik Date: Tue, 4 Mar 2003 16:31:09 +0000 Subject: [PATCH] $CMDLINE may contain quotes fix by brainsucker git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@2232 212acab6-be3b-0410-9dea-997c60f758d6 --- Contrib/System/SysFunc.nsh | 38 ++++++++++++++++++++++++++++++++++++++ Contrib/System/System.nsi | 6 ++++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/Contrib/System/SysFunc.nsh b/Contrib/System/SysFunc.nsh index c914a895..ecf5fe57 100644 --- a/Contrib/System/SysFunc.nsh +++ b/Contrib/System/SysFunc.nsh @@ -13,6 +13,44 @@ !include "${NSISDIR}\Include\WinMessages.nsh" !verbose 4 +; ================= GetInstallerExeName implementation ================= + +; Adopted Get Parameter function -> now it gets full installer.exe path +; input - nothing, output -> full path at the top of the stack +Function GetInstallerExeName + Push $R0 + Push $R1 + Push $R2 + StrCpy $R0 $CMDLINE 1 + StrCpy $R1 '"' + StrCpy $R2 1 + StrCmp $R0 '"' loop + StrCpy $R1 ' ' ; we're scanning for a space instead of a quote + loop: + StrCpy $R0 $CMDLINE 1 $R2 + StrCmp $R0 $R1 loop2 + StrCmp $R0 "" loop2 + IntOp $R2 $R2 + 1 + Goto loop + loop2: + + ; Ok, have we found last exename character or string end? + StrCmp $R0 "" "" +2 + IntOp $R2 $R2 - 1 ; last exename char + StrCmp $R1 ' ' +3 ; was first character the '"', or something other? + StrCpy $R1 1 ; it was quote + Goto +2 + StrCpy $R1 0 + IntOp $R2 $R2 - $R1 + StrCpy $R0 $CMDLINE $R2 $R1 + + GetFullPathName $R0 $R0 ; expand file name to full path + + Pop $R2 + Pop $R1 + Exch $R0 +FunctionEnd + ; ================= systemGetFileSysTime implementation ================= !macro smGetFileSysTime FILENAME diff --git a/Contrib/System/System.nsi b/Contrib/System/System.nsi index 52356cf7..a638d002 100644 --- a/Contrib/System/System.nsi +++ b/Contrib/System/System.nsi @@ -97,11 +97,13 @@ enumex: ; End of drives or user cancel System::Free $1 ; ----- Sample 6 ----- systemGetFileSysTime demo ----- + Call GetInstallerExeName + pop $0 - !insertmacro smGetFileSysTime $CMDLINE + !insertmacro smGetFileSysTime $0 System::Call '*$R0${stSYSTEMTIME}(.r1, .r2, .r3, .r4, .r5, .r6, .r7, .r8)' - MessageBox MB_OK "GetFileSysTime example: file '$CMDLINE', year $1, month $2, dow $3, day $4, hour $5, min $6, sec $7, ms $8" + MessageBox MB_OK "GetFileSysTime example: file '$0', year $1, month $2, dow $3, day $4, hour $5, min $6, sec $7, ms $8" ; free memory from SYSTEMTIME System::Free $R0