Writing license text to file
Is there any way to write a license text to file during installation (e.g. ->"License.txt") in a multilanguage installer (provided that I have a LangString and a LicenseLangString with corresponding source file name)?
Archive: Writing license text to file
Writing license text to file
Is there any way to write a license text to file during installation (e.g. ->"License.txt") in a multilanguage installer (provided that I have a LangString and a LicenseLangString with corresponding source file name)?
Hi Ippi!
As far as I can see, just write the content of the variable $(MUILicense) with FileOpen, FileWrite to a file.
This should work.
Have a nice day!
Cheers
Bruno
Re: Writing license text to file
Originally posted by IppiWhat are you want to do?
Is there any way to write a license text to file during installation (e.g. ->"License.txt") in a multilanguage installer (provided that I have a LangString and a LicenseLangString with corresponding source file name)?
Re: Re: Writing license text to file
Originally posted by bholligerThanks, Bruno, I'll try this method today. Actually, I'm confused by the statement about the LicenseLangString from the NSIS manual: "Does the same as LangString only it loads the string from a text/RTF file and defines a special LangString that can be used only by LicenseData".
As far as I can see, just write the content of the variable $(MUILicense) with FileOpen, FileWrite to a file.
Originally posted by glory_manSorry if I was unclear.
What are you want to do?
Hi Ippi!
Yes, this will do the job:
ClearErrors
FileOpen $0 $INSTDIR\license.txt w
IfErrors done
FileWrite $0 "$(MUILicense)"
FileClose $0
done:
Hi, Bruno!
It does not work really as it should.
It writes only first 1022 bytes of license text, prepending the license data with 0x01 byte (1023 bytes total).
:(
Yoy can use following code
!include "LogicLib.nsh"
...
LangString name ${LANG_ENGLISH} "eng_name"
LangString name ${LANG_RUSSIAN} "rus_name"
LangString name ${LANG_FRENCH} "fr_name"
...
;copy license file - somewhere in section
${Switch} $LANGUAGE
${Case} ${LANG_ENGLISH}
File "/oname=license.txt" "eng_lic.txt"
${Break}
${Case} ${LANG_RUSSIAN}
File "/oname=license.txt" "rus_lic.txt"
${Break}
${Case} ${LANG_FRENCH}
File "/oname=license.txt" "fr_lic.txt"
${Break}
${EndSwitch}
Originally posted by glory_manIt's exactly what I meant by
Yoy can use following code
Of course, I can do something like multiple "IntCmp $LANGUAGE ${LANG_language} ..." and "File /oname=License.txt "${_language_LICENSE_FILE_}"", but I was looking for more elegant solution.slightly brushed by LogicLib macroses :)
What about this code:
LangString name ${LANG_ENGLISH} "lic_eng.txt"
LangString name ${LANG_RUSSIAN} "lic_rus.txt"
LicenseLangString MUILicense ${LANG_ENGLISH} "lic_eng.txt"
LicenseLangString MUILicense ${LANG_RUSSIAN} "lic_rus.txt"
.....
ClearErrors
FileOpen $0 license.txt w
FileOpen $3 $(name) r
IfErrors done
read:
FileRead $3 $1
IfErrors readfin
Push $1
Pop $1
FileWrite $0 "$1"
goto read
readfin:
FileClose $0
done:
....
more elegant solution:)?
Hi glory_man!
I might be wrong, but I think the file $(name) is not present at runtime. Except you have all the files in the same directory as the installer. Is this the case?
Have a nice day!
Cheers
Bruno
Originally posted by glory_manbholliger is right, there are no unpacked license files at runtime on a target system.
[B]What about this code:[/B
So, i think easest way is use something like this:
Setoutpath $PLUGINSDIR
File /r "lic\*"
CopyFiles /SILENT "$PLUGINSDIR\$(name)" "PATH\license.txt"
nope, that won't work as stated earlier: licence text is parsed on compile time, not on runtime... no license files are present in $PLUGINSDIR.
what i did to solve it is quite easy:
LangString name ***91;...***93;
>SetOutPath "$INSTDIR\licenses"
>File "ger_lic.txt"
>File "eng_lic.txt"
>***91;...***93;
>Rename "$INSTDIR\licenses\$(name)" "$INSTDIR\license.txt"
>RMDir /r "$INSTDIR\licenses"
basically: extract all files, rename the chosen one to the correct name, delete the rest.
Originally posted by Comm@nder21No, thanks :) I'd rather use the dumb ${Switch}...${Case} method :rolleyes:
extract all files, rename the chosen one to the correct name, delete the rest.
2 NSIS developers
Why the LicenseLangString is so special that it cannot be written back to file? Look how people are suffering from this :D
Originally posted by Comm@nder21My example worked.
nope, that won't work as stated earlier: licence text is parsed on compile time, not on runtime... no license files are present in $PLUGINSDIR.
Setoutpath $PLUGINSDIR
File /r "lic\*"
Originally posted by Ippi:)
I'd rather use the dumb ${Switch}...${Case} method
yes, this will work but does not differ very much from my method :) except of the folder the licenses are extracted to on runtime :)
Originally posted by glory_manI don't like the glory_man-Comm@nder21 (:)) approach because it unnecessarily burdens the CPU, HDD/file system, anti-viral software and still not so elegant as that hypothetic method I've expected to find :D
Что за пользователи пошли - то не Ñтак, Ñто не так.
:D :D :D
Originally posted by Comm@nder21:D :D :D
yes, this will work but does not differ very much from my method :) except of the folder the licenses are extracted to on runtime :)
2 Ippi
Also you can use macro like this:
!macro addlicense language licname folder var1name var2name
!insertmacro MUI_LANGUAGE "${language}"
LangString ${var1name} '"$$""{LANG_${language}"}' "${licname}"
LicenseLangString ${var2name} '"$$""{LANG_${language}"}' "${folder}\${licname}"
!macroend
!insertmacro addlicense ENGLISH "historyeng.txt" "lic" name MUILicense
!insertmacro addlicense RUSSIAN "historyeng.txt" "lic" name MUILicense
!insertmacro addlicense FRENCH "historyfr.txt" "lic" name MUILicense
Originally posted by glory_manJust the extraction code embarrasses me, not the declaration part ;)
Code to extract of license stay previous.
Originally posted by IppiI think extraction of few files of some kilobytes will not make heavy CPU load.
Just the extraction code embarrasses me, not the declaration part ;)
Originally posted by Ippi
Why the LicenseLangString is so special that it cannot be written back to file? Look how people are suffering from this :D
The license string is too large. It's over the 1024 bytes limit of internal strings.