dcbrewster
21st February 2011 21:43 UTC
CopyFiles [size_of_files_in_kb]
Compilation Problem - not execution problem.
I cannot get the CopyFiles command to accept the optional parameter of [size_of_files_in_kb]. I have tried every combination of syntax that I can think of but no go. When I replace the "${DIRSIZE}" variable on the command line with a value such as 100 or "100", the compile works fine.
Any suggestions?
Script Extract
Function .onInit
${GetSize} "$EXEDIR\corrected" "/S=1K" $0 $1 $2 ;Get Directory Size
!define DIRSIZE $0 ;Save Directory Size
MessageBox MB_OK "Size is ${DIRSIZE} Kb"
IfErrors 0 End ;Errors?
MessageBox MB_ICONSTOP "Error:$\n$\nFiles not found." ;Message To User
Abort ;Abort Installation
End:
FunctionEnd
Section "MainSection" SEC01
SetOutPath "$INSTDIR" ;Set/Confirm Destination
SetOverwrite ON ;Overwrite Files
CopyFiles /SILENT "$EXEDIR/corrected/*.*" "$INSTDIR" "${DIRSIZE}" ;Copy files
SectionEnd
BTW: Looks like the NSIS Help file needs to be corrected.
NSIS Help File
[/SILENT] [/FILESONLY] filespec_on_destsys destination_path [size_of_files_in_kb]
HM NSIS Editor Prompt
[/SILENT] [/FILESONLY] source_path destination_path [size_of_files_in_kb]
demiller9
21st February 2011 23:30 UTC
Can't use runtime commands during Compile time
Everyone has the same confusion: Variables assigned to defined constants don't do what they expect. In this case you are telling the compiler that the number of KB that will be used for the copy is "$0". That is not a value the compiler can handle. You need to put the actual size in your source, don't try to do it at runtime, that doesn't work.
dcbrewster
22nd February 2011 00:41 UTC
But, I don't know the size.
Thanks, but I don't know the size of the files to be copied. The files are outside the installation routine.
The two other copyfiles parameters accept variables but not the third?
Without the size parameter the Install Directory dialog will show 0 disk requirements.
I get the proper size via getsize but can't tell the user.
Dave
demiller9
22nd February 2011 06:17 UTC
It sounds like you are looking for SectionSetSize. Make sure you move the .onInit function in your code... the sections have to be declared before you reference the section ids.
Section "MainSection" SEC01
SetOutPath "$INSTDIR" ;Set/Confirm Destination
SetOverwrite ON ;Overwrite Files
CopyFiles /SILENT "$EXEDIR/corrected/*.*" "$INSTDIR" ;Copy files
SectionEnd
Function .onInit
${GetSize} "$EXEDIR\corrected" "/S=1K" $0 $1 $2 ;Get Directory Size
SectionSetSize ${SEC01} $0
MessageBox MB_OK "Size is $0 Kb"
IfErrors 0 End ;Errors?
MessageBox MB_ICONSTOP "Error:$\n$\nFiles not found." ;Message To User
Abort ;Abort Installation
End:
FunctionEnd
dcbrewster
22nd February 2011 06:40 UTC
That Worked
demiller9,
SectionSetSize did the job. Always more to learn.
Thanks for your help.
Dave