On 01/17/2018 10:20 AM, Luc Moulinier wrote:
> Hello all,
>
> First of all, my best wishes of health and happiness for this new year !
>
> What is the best way to test if a user can save a file in a givent place ? My solution is :
>
> ...
> set file [tk_getSaveFile -filetypes $types -initialfile $FichierParDefaut]
> if {$file ne ""} {
> if {[catch {set o [open $file w]}]} {
> FaireLire "Error !\nWrite-protected !"
> set file ""
> } else {
> # let's caller manage opening
> close $o
> file delete $file
> }
> }
> return $file
>
> Is there a better way to do so ? Checking the directory means checking ownership and permission rights ...
Read the file man/help page. Pay particular attention to the section on
the writable subcommand.
> Shouldn't this functionallity be included in tk_getSaveFile ?
Sounds good, but.. tk_getSaveFile utilizes native dialogs on some
platforms (to give the proper look and feel) that do not support such
functionality (or at least they did not and, to the best of my knowledge
still do not). Thus the answer is: No.
--
+----------------------------------------------------------------------+
| Gerald W. Lester, President, KNG Consulting LLC |
| Email:
Gerald...@kng-consulting.net |
+----------------------------------------------------------------------+