Skip to content
⌘ NSIS Forum Archive

Optional Components page and required size

5 posts

kalverson#

Optional Components page and required size

I am running into an issue with the calculated required size always ending up as zero. There are no files install in the always there sections, so am wondering if this is something I need to do extra to get some size specified for the optional components when they are selected.
kalverson#
Thank you for the quick reply. yes I knew you could do that and it works correctly too when I tried it, but it would be nice if the size could be accurate as well. I don't mind adding the manual arithmetic if there is an easy way to extract the "File myfile.jar" size from the File directive. Is it because I call a function in the optional section component where the File directive is located in the called function that I don't get any size filled in?
Anders#
Yes, the File instruction needs to be in a Section for the size to count (File instructions in Functions do not count because they can be called from multiple places or in a loop).

Is there a easy way to add the size of arbitrary files? No, not really but it can be done:

!tempfile addsize
!system `FOR %A IN ("c:\windows\*.exe") DO @(set /A s=%~zA / 1024&(^>^> "${addsize}" call echo AddSize %s%))`
!include "${addsize}"
!delfile "${addsize}"
kalverson#
Thank you Anders. Just a quick reply to let you know we resolved our issues by moving all the file instructions back into the optional sections and making sure there were no function calls that included any sort of file directive. Then the required size started working again. There must be some internal logic which disables the required size calculation if a File directive is found inside a function call from any of the section logic.