![]() |
#1 |
Junior Member
Join Date: Jun 2013
Posts: 16
|
Problems with CopyFiles
Hi,
sorry i'm new in working with nsis. I want to copy files using CopyFiles: CopyFiles "$INSTDIR\$Save" "$INSTDIR\saved" $Save is a relative path like logs\log.txt The command obove does not work!!! But if the command is: CopyFiles "$INSTDIR\logs\log.txt" "$INSTDIR\saved" it WORKS! I can not understand why! Why can't i use a Variable in the source? Thanks for helping! NC10 |
![]() |
![]() |
![]() |
#2 |
Major Dude
Join Date: Oct 2006
Posts: 1,892
|
As far as I know CopyFiles is a normal runtime command so, unlike the File command, you should be able to use variables as parameters. If it's not working, most probably the value of the variable is wrong. Put this before the command to check:
MessageBox MB_OK "$INSTDIR\$Save" It could also be that the $INSTDIR\saved doesn't exist yet, in which case it would copy it to a file called 'saved' inside $INSTDIR. First SetOutPath "$INSTDIR\saved" to create the directory. |
![]() |
![]() |
![]() |
#3 |
Junior Member
Join Date: Jun 2013
Posts: 16
|
Thank you very much!
I think the command CopyFiles also can't handle Variables as Parameters. If i use !define it works. So far: I have another Problem. I want to read out filenames (relative pathes) out of a file with FileRead, like: FileRead $0 $Save (in a Loop) So $Save contains the first line of a file and in my case it contains a relative path, for example "logging.log". If i compare $Save with "logging.log", it does not match. Means: ${If} $Save == "logging.log" MessageBox "JA" ${EndIf} does not work!!! Although DetailPrint $Save prints "logging.log" I cannot understand why! I really need help! Maybe there is any Encoding Problem? What can i do? Thank you for help! |
![]() |
![]() |
![]() |
#4 |
Major Dude
Join Date: Oct 2006
Posts: 1,892
|
|
![]() |
![]() |
![]() |
#5 |
Junior Member
Join Date: Jun 2013
Posts: 16
|
Hey thanks for answer:
But i cannot see any difference?!?! my code: ${If} $Save == "logging.log" MessageBox MB_OK "Ja!" ${EndIf} (I only forgot to write MB_OK and the formatting in the post is wrong, in my code it is right) What's wrong? |
![]() |
![]() |
![]() |
#6 |
Major Dude
Join Date: Feb 2007
Posts: 672
|
Please note that the If statement is case sensitive.
Also check if there are leading or trailing spaces in $Save. |
![]() |
![]() |
![]() |
#7 |
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
The == and != operators are not case sensitive. S== and S!= are, however.
Stu |
![]() |
![]() |
![]() |
#8 |
Major Dude
Join Date: Feb 2007
Posts: 672
|
Ah, sorry, you're right, I was too quick on checking the wiki page.
|
![]() |
![]() |
![]() |
#9 | |
Junior Member
Join Date: Jun 2013
Posts: 16
|
Quote:
Now my Code: FileOpen $0 "$INSTDIR\test_text.txt" r ; open and read line by line Loop: IfErrors Done FileRead $0 $Line ;DetailPrint "$Line!" ${un.Trim} $withoutSpaces $Line Goto Loop Done: FileClose $0 The code works, but one more problem: At the end of the file, my loop always reads (and print) an empty line. I don't know why. I thought the loop only works until either a newline (or carriage return newline pair) occurs, or until a null byte is read (see docu). Any idea? Thanks. |
|
![]() |
![]() |
![]() |
#10 |
Major Dude
Join Date: Feb 2007
Posts: 672
|
Maybe obvious, but are you sure there's not actually a newline at the end of your file?
|
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|