2013-03-18 56 views
0

我希望有一個功能可以將某些文件添加到某個文件夾中,因爲我需要添加更多文件。nsis文件夾參數目錄

這裏是我的功能代碼:

Function "addElement" 
    DetailPrint $0 
    CreateDirectory $INSTDIR\data\Element\$0 
    SetOutPath $INSTDIR\data\Element\$0 

    File /r "${binFolder}\data\Element\$0\*.*" 
FunctionEnd 

,在這裏我把它叫做:

strcpy $0 "Element_1" 
call "addElement" 

strcpy $0 "Element_2" 
call "addElement" 

strcpy $0 "Element_3" 
call "addElement" 

的NSIS給出了這樣的錯誤:

在該行File /r...- >沒有找到文件。

回答

1

$0是一個變量,變量在運行時使用,File指令需要在編譯時知道文件名!

與宏替換功能:

!macro addElement fname 
    DetailPrint "${fname}" 
    CreateDirectory "$INSTDIR\data\Element\${fname}" 
    SetOutPath "$INSTDIR\data\Element\${fname}" 

    File /r "${binFolder}\data\Element\${fname}\*.*" 
!macroend 

... 

Section 

!insertmacro addElement foo 
!insertmacro addElement bar 
!insertmacro addElement baz 
+0

感謝@Anders,它工作正常! – ghiboz 2013-03-18 16:06:40