hv When running in a shared environment, I often need to determine if a file belongs to me or not. Here is how I do it, if you know a different way, please contribute.
package require Tclx
#
# Does this file belong to me?
#
proc fileIsMine {fileName} {
if {![file exists $fileName]} { return 0 }
file stat $fileName stat
if {$stat(uid) == [id userid]} {
return 1
} else {
return 0
}
}
#
# Rough test
#
set allFiles [glob -nocomplain /tmp/*]
set myUid [id userid]
foreach f $allFiles {
file stat $f filestat
if {[fileIsMine $f]} {
puts "mine - $f"
} else {
puts "not mine - $f"
}
}DKF: An alternative approach is to use file owned. That can answer this question, but only this question; it doesn't say anything about who owns the file if it is owned by anyone else.
hv Thank you DKF. That shows how little I know.