Archive: MUI_DIRECTORYPAGE Question


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


Is .onVerifyInstDir - callback function what you wanted?


actually I had hopped that NSIS would check at least for writepermissions automatically?!?!?


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

Thanks, this seems awfully complicated just to check write permissions. I will try it and post my experiences :) Thanks again.
patrick


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) ;)



; 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.

thanks stb,

this one seems to be working :)

patrick