Old 12th January 2005, 13:05   #1
Odeamus
Junior Member
 
Join Date: Jan 2005
Posts: 2
How to copy a single file?

I have a problem with copying files one at a time. I'm trying to do a section where I read a string from a file and the use it to determine if a file exists in some directory. If it doesn't exists a file corresponding to the string will be copied to the target directory from a temp directory, if the file(in some form, <string>-*.jar) exists the user will be asked if (s)he wants to overwrite the old file with the new.

For now I'm just trying to copy all the files one at a time using CopyFiles, but I usually get an error or nothing happens.

Something like this:

FileOpen $1 "$INSTDIR\strings.txt" "r"

loop:
FileRead $1 $2
IfErrors done

CopyFiles /FILESONLY "$INSTDIR\somedir\$2*.jar" "$TARGETDIR"

IfErrors copyFailed
Goto loop

done:
MessageBox MB_OK "Done."
FileClose $1
Return

copyFailed:
MessageBox MB_OK "Copy operation failed."
FileClose $1
Return

O.
Odeamus is offline   Reply With Quote
Old 12th January 2005, 13:54   #2
Comm@nder21
Major Dude
 
Join Date: Jul 2003
Location: germany, b-w
Posts: 734
Send a message via ICQ to Comm@nder21
IfFileExists checks if your file is already existing in $TARGETDIR.

for string operations, use TextFunc.nsh and WordFunc.nsh.

there's a forum thread somewhere, where the current versions are posted regularly.
Comm@nder21 is offline   Reply With Quote
Old 13th January 2005, 17:32   #3
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
See the following FAQ item:

http://nsis.sourceforge.net/index.ph...&tx_faq_faq=20

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 13th January 2005, 19:01   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
"Delete/FileOpen/CopyFiles don't work"
Please change it "do not" or "doesn't"!

-Stu
Afrow UK is offline   Reply With Quote
Old 14th January 2005, 06:15   #5
Odeamus
Junior Member
 
Join Date: Jan 2005
Posts: 2
Thanks all. Figured it out on my own.
The problem were the new line characters. I got the imression from the help that those characters wouldn't be in the string, so that didn't come to mind until yesterday.

O.
Odeamus is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump