Permalink
Browse files

Fix for Issue # 22 - work around for tcl bug 1852572 - "file writable"

command broken on Windows accessing samba shares from Linux server.
  • Loading branch information...
1 parent 9d84d03 commit 7c07065c9263b75e4d7279e490a298015f41d04b @rich123 rich123 committed Mar 18, 2012
Showing with 9 additions and 2 deletions.
  1. +9 −2 sources/gorilla.tcl
View
@@ -4267,9 +4267,13 @@ proc gorilla::Save {} {
# If not writable, give user the option to change it to writable and
# retry, or to abort the save operation entirely
#
+ # Work around tcl-Bugs-1852572 regarding "file writable" and samba mounts
+ # by simply attempting to open the file in write only append mode (append
+ # so as not to destroy the file while testing for write access). If the
+ # open succeeds, we have write permission.
+
+ while { [ catch { set fd [ open $::gorilla::fileName {WRONLY APPEND} ] } ] } {
- while { ! [ file writable $::gorilla::fileName ] } {
-
# build the message in two stages:
set message "[ mc "Warning: Can not save to" ] '[ file normalize $::gorilla::fileName ]' [ mc "because the file permissions are set for read-only access." ]\n\n"
append message "[ mc "Please change the file permissions to read-write and hit 'Retry' or hit 'Cancel' and use 'File'->'Save As' to save into a different file." ]\n"
@@ -4282,6 +4286,9 @@ proc gorilla::Save {} {
} ; # end while gorilla::fileName read-only
+ # don't need the open file descriptor once out of the while loop
+ close $fd
+
set myOldCursor [. cget -cursor]
. configure -cursor watch
update idletasks

0 comments on commit 7c07065

Please sign in to comment.