Old 21st February 2011, 21:43   #1
dcbrewster
Junior Member
 
Join Date: May 2010
Posts: 6
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]
dcbrewster is offline   Reply With Quote
Old 21st February 2011, 23:30   #2
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 462
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.
demiller9 is offline   Reply With Quote
Old 22nd February 2011, 00:41   #3
dcbrewster
Junior Member
 
Join Date: May 2010
Posts: 6
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
dcbrewster is offline   Reply With Quote
Old 22nd February 2011, 06:17   #4
demiller9
Senior Member
 
Join Date: Mar 2006
Location: Dallas
Posts: 462
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.
code:
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

demiller9 is offline   Reply With Quote
Old 22nd February 2011, 06:40   #5
dcbrewster
Junior Member
 
Join Date: May 2010
Posts: 6
That Worked

demiller9,

SectionSetSize did the job. Always more to learn.

Thanks for your help.

Dave
dcbrewster is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump