![]() |
#1 |
Member
Join Date: Sep 2012
Posts: 81
|
How to compare two files in NSIS?
I have created exe file using nsis.Installer working both ways silent and non-silent mode.If the user run second time i will take backup old property values and compare new property values.If mismatches i will write old property value into new property.
In the following code compare two and copy into temp file mismatched values. Function compare StrCpy $R0 "$INSTDIR\old.properties" StrCpy $R1 "$INSTDIR\new.properties" GetTempFileName $R2 FileOpen $R3 $R2 w ${TextCompare} "$R0" "$R1" "FastDiff" "Example2" IfErrors 0 +2 MessageBox MB_OK "Error" IDOK +2 Exec "notepad.exe $R2" FunctionEnd Function Example2 FileWrite $R3 '$9' Push $0 FunctionEnd Problem: In the temp File[$R3] have mismatched values.I want to replace mismatched values into new property. How to achieve this?. |
![]() |
![]() |
![]() |
#2 |
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
What is the format of your property files? Can you use ConfigRead/ConfigWrite?
Stu |
![]() |
![]() |
![]() |
#3 |
Member
Join Date: Sep 2012
Posts: 81
|
I dont understand what is the format of your property file?.In my code i have put .properties.
Also how to use config read in this file comparison? Problem: compare two property files named old and new.if any string value mismatches that value should be replaced in new property. |
![]() |
![]() |
![]() |
#4 |
Major Dude
Join Date: Oct 2006
Posts: 1,892
|
Please upload an example property file to pastebin.com .
|
![]() |
![]() |
![]() |
#5 |
Member
Join Date: Sep 2012
Posts: 81
|
#DEFAULT - PATH
DIRECTORY=C:/programfile/myproject INDEXFILE=C:/programfile/myproject/index.xml Temp INDEXFILE=C:/programfile/myprojec/temp.xml DAYS=3 ......... ........ In the above are sample values in property file.Also i have put in pastebin.com. |
![]() |
![]() |
![]() |
#6 |
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
Use ConfigRead/ConfigWrite. It's in the NSIS manual.
Stu |
![]() |
![]() |
![]() |
#7 |
Member
Join Date: Sep 2012
Posts: 81
|
thanks.I have used configwrite for writing mismatched values.but it will raised another problem.
If i use ${ConfigWrite} it will enter ${ConfigWrite} "$INSTDIR\conf.properties" "$R0" " $R1" $R3 $R0 -variable $R1-value After writing property file it will add new line every written.e.g #DEFAULT - PATH DIRECTORY=C:/programfile/myproject INDEXFILE=C:/programfile/myproject/index.xml Temp INDEXFILE=C:/programfile/myprojec/temp.xml DAYS=3 I dont know why this new line added for every writing.How erase this new line ? |
![]() |
![]() |
![]() |
#8 |
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
ConfigRead may not trim new-line characters. Use TrimNewLines on the value before writing it.
Stu |
![]() |
![]() |
![]() |
#9 |
Member
Join Date: Sep 2012
Posts: 81
|
yes.I have tried same function.but i have used after written.Now its working.Thanks.
|
![]() |
![]() |
![]() |
|
Tags |
java, nsis |
Thread Tools | Search this Thread |
Display Modes | |
|
|