NSIS 설치 디렉토리에 ‘/ ‘ 문제
2010-06-29
NSIS에 기본 설치 디렉토리 InstallDir 변수에 C:/Install/1.0 과 같은 식의 패스를 넣어주면 설치가 되지 않는데 굳이 C:\Install\1.0 대신에 C:/Install/1.0 을 넣고자 한다면 NSIS의 다음의 매크로를 이용한다.
!macro StrSlash un Function ${un}StrSlash Exch $R3 ; $R3 = needle ("\" or "/") Exch Exch $R1 ; $R1 = String to replacement in (haystack) Push $R2 ; Replaced haystack Push $R4 ; $R4 = not $R3 ("/" or "\") Push $R6 Push $R7 ; Scratch reg StrCpy $R2 "" StrLen $R6 $R1 StrCpy $R4 "\" StrCmp $R3 "/" loop StrCpy $R4 "/" loop: StrCpy $R7 $R1 1 StrCpy $R1 $R1 $R6 1 StrCmp $R7 $R3 found StrCpy $R2 "$R2$R7" StrCmp $R1 "" done loop found: StrCpy $R2 "$R2$R4" StrCmp $R1 "" done loop done: StrCpy $R3 $R2 Pop $R7 Pop $R6 Pop $R4 Pop $R2 Pop $R1 Exch $R3 FunctionEnd !macroend !insertmacro StrSlash "" !insertmacro StrSlash "un."
그리고 다음과 같이 이용한다.
Push $INSTDIR; c:\this\and\that\filename.htm Push "\" Call StrSlash Pop $R0 ; Now $R0 contains 'c:/this/and/that/filename.htm'
Uninstall 섹션에서는 다음과 같이 호출한다.
.. Call un.StrSlash ..
Categorized as: Programming
답글 남기기