file readable

file readable, a subcommand of file, returns 1 if name is readable by the current user, and 0 otherwise.

Synopsis

file readable name

Description

When file readable returns 1, it does not necessarily mean that "open file r" will succeed. For example, file readable might return 1`, but open fails because someone has a write lock.

On NTFS volumes, file readable doesn't currently take account of the more complex Windows user/group stuff, so can return the wrong value. Code contributions using GetSecurityInfo() much appreciated.

RS 2007-02-16: Quick workaround:

proc file'readable name {
    set rc [catch {open $name} fp]
    if {$rc==0} {close $fp}
    expr {$rc==0}
}

jdc 2007-10-23: After upgrading from Tcl 8.4.9 to 8.4.16, I experienced problems with file readable for file on a SMB mount. file readable always returns 0, unless the others have read privilege on the file. Tcl 8.5b1 has the same behavior.

HaO 2015-02-19: confirming that the issue exists also in 8.6.3. See bug 1613456 . file exists is not affected.