stopasking
27th November 2011 19:29 UTC
Conditional copying and section size
Hello,
I have something like that:
Section "$(STRING_SECTION_MAIN)" SecMain
SectionIn 1 RO
; Set output path to the installation directory.
SetOutPath $INSTDIR
${If} $Portable == 0
File "/oname=1.exe" "${EXE}"
; Write the installation path into the registry
WriteRegStr HKCU "Software\test" "install_dir" "$INSTDIR"
${Else}
File "/oname=bin\1.exe" "${EXE}"
File "/oname=launcher.exe" "${LAUNCHER}"
${EndIf}
SectionEnd
It works fine, except that the main file, "${EXE}", is calculated twice in the file size of the section. I thought there's maybe a flag for "File" to exclude it from size calculation, but I didn't find any.
Thanks.
Anders
27th November 2011 21:45 UTC
Use this workaround:
Section
var /GLOBAL Portable
StrCpy $Portable 1
!define EXE "${__FILE__}"
StrCpy $0 $outdir\1.exe
${If} $Portable <> 0
CreateDirectory $outdir\bin
StrCpy $0 $outdir\bin\1.exe
${EndIf}
File "/oname=$0" "${EXE}"
SectionEnd
or adjust size with SectionSetSize in .onInit
stopasking
27th November 2011 22:00 UTC
> or adjust size with SectionSetSize in .onInit
How do I do that?
Is there a function to calculate a file size at compile time?
Anders
28th November 2011 00:17 UTC
Originally posted by stopasking
> or adjust size with SectionSetSize in .onInit
How do I do that?
Is there a function to calculate a file size at compile time?
Yes and no, there is no real compile time function to get the size of a file but you can call !system and put the size as a define in a .nsh that you include...
stopasking
28th November 2011 14:14 UTC
Can you please provide more details? An example maybe?
I found no info about using !system for getting a size of a file...
MSG
28th November 2011 17:01 UTC
You can use !system to execute a vbs script, bat, exe, whatever. You'll need to build that script/exe to create an .nsh file with the size-specific code you need.