PatrickFraley
7th April 2005 13:20 UTC
MUI_DIRECTORYPAGE Question
Hi All,
I have a little odity in the MUI_DIRECTORYPAGE. The Dialog allows the user to select a folder which is write protected. this does seem kind of odd, should it not prevent the selection of writeprotected folders. the install finishes and acts like everything went ok, but the files did not get installed. do I have to write a custom function to check for permisions (I would think not, since there is the MUI_DIRECTORYPAGE_VERIFYONLEAVE var, which allows me to do it, but it also says that if not used it will disable the next button if the folder is invalid, what is an invalid folder anyhow?)
Tia
Patrick
glory_man
7th April 2005 13:39 UTC
Is .onVerifyInstDir - callback function what you wanted?
PatrickFraley
7th April 2005 14:04 UTC
actually I had hopped that NSIS would check at least for writepermissions automatically?!?!?
Afrow UK
7th April 2005 15:56 UTC
It seems not.
To test, this should work:
Function .onVerifyInstDir
ClearErrors
FileOpen $R0 "$INSTDIR\temp.tmp" w
FileWrite $R0 ""
FileClose $R0
IfErrors 0 +3
MessageBox MB_OK|MB_ICONEXCLAMATION "Selected folder is not writable!"
Abort
Delete "$INSTDIR\temp.tmp"
FunctionEnd
-Stu
PatrickFraley
8th April 2005 08:31 UTC
Thanks, this seems awfully complicated just to check write permissions. I will try it and post my experiences :) Thanks again.
patrick
PatrickFraley
8th April 2005 08:38 UTC
Ok I tried it and it does not work, I never have write Permissions on the selected folder, since the folder does not yet exist (at least on a new install) ;)
stb
8th April 2005 09:44 UTC
; add this function
Function LeaveDirectoryPage
ClearErrors
SetOutPath "$INSTDIR"
Push $0
FileOpen $0 "<UNIQUEKEY>.dummy" "w"
FileWriteByte $0 "0"
FileClose $0
Pop $0
Delete "$INSTDIR\<UNIQUEKEY>.dummy"
IfErrors 0 finish
MessageBox MB_OK|MB_ICONSTOP "not writable"
Abort
finish:
FunctionEnd
; IMPORTANT: replace <UNIQUEKEY> with some unique key (GUID ist good)!
; insert !define MUI_PAGE_CUSTOMFUNCTION_LEAVE LeaveDirectoryPage
; before !insertmacro MUI_PAGE_DIRECTORY
.onVerifyInstDir is not best here as that would (try) create directories before the user really wants to. Therefore I use the solution above.
PatrickFraley
8th April 2005 09:57 UTC
thanks stb,
this one seems to be working :)
patrick