FileCopy: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Wikipedia python library)
 
(split infinitive)
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{PageAuthor|Joel}}
== Description ==
This macro causes "CopyFiles" not to set the error flag when copying files to an non-existant folder by first attempting to create the destination folder.
== How To Use ==
<highlight-nsis>
${FileCopy} `filespec_on_destsys` `destination_path`
</highlight-nsis>
== The Script ==
== The Script ==
<highlight-nsis>
<highlight-nsis>
;This macro will help you copy a file to
!define FileCopy `!insertmacro FileCopy`
;diferent directory (or directories) without compile it twice.
;Enjoy.
;Sorry for my really bad english. :D
;Script based in ${NSISDIR}\Examples\Example1.nsi
;you can use this macro as many times you want in your script
 
!macro FileCopy FilePath TargetDir
!macro FileCopy FilePath TargetDir
;Now the macro create the dir first :)
  CreateDirectory `${TargetDir}`
;If the dir doesn't exists, It'll be created.
  CopyFiles `${FilePath}` `${TargetDir}`
CreateDirectory ${TargetDir}
CopyFiles ${FilePath} ${TargetDir}
!macroend
!macroend
Name "CopyME"
OutFile "copyme.exe"
InstallDir $PROGRAMFILES\CopyMe
DirText "Select a dir, Dude"
Section "ThisNameIsIgnoredSoWhyBother?"
SetOutPath $INSTDIR
File "${NSISDIR}\makensisw.exe"
File "me.txt"
!insertmacro FileCopy "$INSTDIR\makensisw.exe" "$INSTDIR\copy"
!insertmacro FileCopy "$INSTDIR\me.txt" "$INSTDIR\backup"
!insertmacro FileCopy "$INSTDIR\me.txt" "$SYSDIR"
SectionEnd
</highlight-nsis>
</highlight-nsis>


Page author: Joelito
[[Category:Disk, Path & File Functions]]

Latest revision as of 17:25, 29 March 2010

Author: Joel (talk, contrib)


Description

This macro causes "CopyFiles" not to set the error flag when copying files to an non-existant folder by first attempting to create the destination folder.

How To Use

${FileCopy} `filespec_on_destsys` `destination_path`

The Script

!define FileCopy `!insertmacro FileCopy`
!macro FileCopy FilePath TargetDir
  CreateDirectory `${TargetDir}`
  CopyFiles `${FilePath}` `${TargetDir}`
!macroend