Re: figuring out a filename from it's handle...
- From: Bezoar <cwjolly@xxxxxxxxx>
- Date: Fri, 31 Aug 2007 05:55:00 -0000
On Aug 30, 4:53 pm, daneyu...@xxxxxxxxx wrote:
If I've lost track of a filename that a channel was opened for, is
there a way to get the filename from just the channel name?
In other words, after doing the following:
set file_handle [open $filename r]
can I then use $file_handle to determine $filename?
-Daniel
just override your open call to creat an array of file descriptors
and their associated filenamss, or what not. Overload close to remove
from the global array
global fd2filename
array set { stdin stdin stdout stdout stderr stderr }
rename open Open
proc open { args } {
global fd2filename
set fname { lindex $args 0 ]
set fd [ eval Open $args ]
set fd2filename($fd) $filename
return $fd;
}
..... do same thing for close except you remove
the array index from the global array and when
you want to find out what the filename is you
merely
set fd [ open /tmp/log.file "r" 0660 ]
puts "filename for fd is $fd2filename($fd)"
I probably forgot something as I did not test this
out but it should work.
Carl
.
- Follow-Ups:
- Re: figuring out a filename from it's handle...
- From: Glenn Jackman
- Re: figuring out a filename from it's handle...
- References:
- figuring out a filename from it's handle...
- From: daneyuleb
- figuring out a filename from it's handle...
- Prev by Date: Re: TCL editor recommendation
- Next by Date: Re: catch replacing useful errorInfo
- Previous by thread: Re: figuring out a filename from it's handle...
- Next by thread: Re: figuring out a filename from it's handle...
- Index(es):
Relevant Pages
|