FileOpen in a not permitted directory
Hello!
I tried to use the following script to determine, wether the user has the permission to write into the installation directory or not.
Function OnDirLeave
ClearErrors
SetOutPath $INSTDIR
FileOpen $0 "test.dat" "w"
;StrCmp $0 "" notPossible possible
IfErrors notPossible possible
notPossible:
MessageBox MB_OK "Not able to write into this directory!"
Abort
possible:
FileClose $0
FunctionEnd
According to the helpfile and what I'm used to when working with files under windows, it should have worked, what means, that FileOpen should not have worked.
But it did! Checking the permissions with this function failed!
So I tried the following one, which solved the problem:
Function OnDirLeave
ClearErrors
SetOutPath $INSTDIR
FileOpen $0 "test.dat" "w"
FileWriteByte $0 "0"
IfErrors notPossible possible
notPossible:
MessageBox MB_OK "Not able to write into this directory!"
Abort
possible:
FileClose $0
Delete "$INSTDIR\test.dat"
FunctionEnd
Now my question is, if anyone can explain to me, why the first version didn't work!
TIA
Christian
P.S.: Please excuse my poor english!