- NSIS Discussion
- How to clear temp folder?
Archive: How to clear temp folder?
thico_
6th January 2005 12:37 UTC
How to clear temp folder?
My installer extracts silence.mp3 to the $TEMP and I have one problem with it. If any user will click Install, temp folder is cleared, cause there's following code in Section/SectionEnd:
[...]
Delete "$TEMP\silence.mp3"
[...]
But what if user will abort the installation? silence.mp3 won't be erased from the temp dir :/ Any idea how to delete it? :/
RobGrant
6th January 2005 12:39 UTC
You could use the $PLUGINSDIR instead, far as I know that's deleted on cancel as well.
Otherwise, just add Delete "$TEMP\silence.mp3" into your .onUserAbort function.
thico_
6th January 2005 12:43 UTC
Thank you very much! I'll check both options :D
thico_
6th January 2005 12:45 UTC
Oh! One more question! Where $PLUGINSDIR stores temporary files?
saivert
6th January 2005 13:31 UTC
$PLUGINSDIR is a variable that is assigned on runtime. It will point to a directory under $TEMP, "$TEMP\nst023.tmp\" is a good example. The installer will delete all files in this directory and then remove the directory when the installer quits. To set this up, simply call InitPluginsDir in the installer's .onInit callback function.
RobGrant
6th January 2005 13:52 UTC
You can just MessageBox MB_OK "$PLUGINSDIR" to see it, it'll change each time.
thico_
6th January 2005 14:06 UTC
Thanks!!!
I have a new problem :(
When I'm using $PLUGINSDIR silent.mp3 is removed but nsis temp folders containing files such as nsis logo, etc (which are created in temp dir) are not erased! And when I want to use...
Function .onUserAbort
Delete "$TEMP\silence.mp3"
FunctionEnd
...I got an error:
Function: ".onUserAbort"
Error: Function named ".onUserAbort" already exists.
But there *isnt* already existing function with such name! What's wrong?
RobGrant
6th January 2005 14:12 UTC
You're using the MUI. You need to err do something clever.
*Looks it up*
Yes, use a custom function. MUI (annoyingly :)) defines its own .onUserAbort, so you have to define your own function which MUI somehow mashes into the original. You do this:
!define MUI_CUSTOMFUNCTION_ABORT "customAbortFunction"
Function "customAbortFunction"
Delete "$TEMP\silence.mp3"
FunctionEnd
thico_
6th January 2005 14:23 UTC
:D
I really appreciate it, thanks!