Prev Previous Post   Next Post Next
Old 16th April 2010, 11:27   #14
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
Quote:
It's extremely simple to do this in script alone.
Since when? :x

Not that I'm advocating this patch per se - but unless I missed something, you're going to need quite a bit of code to actually get this sort of behavior out of NSIS. There's probably examples in the wiki that make it easier because you don't have to come up with something from scratch*, but...

For single files, you'd have to define a macro that replaces the File command you'd normally use which...
1. Checks if the file exists
2. If it does, creates a backup*
3. Tries to overwrite the file
3a. If it succeeds - great, done
3b.1 If not, delete the backup
3b.2 Catch the error with custom handling if desired (see some other thread on this)
* and in the backup section check if you can actually back up to the location you want to back up to.

And that's single files. As soon as you use the File command to include multiple files or files recursively, you have to either... A. Drop that construction entirely and make a pre-installer build installer that generates a file inclusion list for the actual installer, or B. First extract the files to a temporary location and instead of using the File command to place the files directly, find the files that were created in the temporary location and use CopyFiles and CreateDirectory instead (further handling is similar to the above).

You'd need these as separate macros as well - or as a single macro but for 'single file' calls you'd have to explicitly indicate that it is such. e.g.
!macro macroname source dest recursive
For a single file would always have to specify the 'recursive' bit as being 'false', '0', or whatever one chooses.
This applies for every parameter in the File command that you'd want to support. Adding support for /x (exclude files) means adding another parameter... now a single file call might end up looking like:
${macroname} "somefile.ext" "$InstDir\somefile.ext" 0 0
Alternatively you'd have to define them before your call.. or callS in which case you have to make sure you don't forget to undefine them afterward.. etc.

It's not impossible, but 'extremely simple' is not how I would choose to describe it in general
Animaether is offline   Reply With Quote
 
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