Mirko Vukovic | 3 Feb 18:30
Picon

how to access a stream's file descriptor

Hello,

when I print a stream associated with an open file, I can see the file name there.

How can I query the stream to get the associated file name?

(I did look in the manual, and looked under sb-sys, but found nothing.)

Thank you,

Mirko

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Sbcl-help mailing list
Sbcl-help <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-help
Kalyanov Dmitry | 3 Feb 18:41
Picon
Gravatar

Re: how to access a stream's file descriptor

Hello,

On Fri, 2012-02-03 at 12:30 -0500, Mirko Vukovic wrote:
> Hello,
> 
> when I print a stream associated with an open file, I can see the file
> name there.
> 
> How can I query the stream to get the associated file name?
> 
> (I did look in the manual, and looked under sb-sys, but found
> nothing.)
> 

SBCL's file streams are instances of SB-SYS:FD-STREAM.

You can query a file stream for FD (file descriptor) and file name like
this:

(with-open-file (file "/home/dvk/1.xml")
  (values (sb-sys:fd-stream-fd file)
          (pathname file)))
=>
5
#P"/home/dvk/1.xml"

According to CLHS, (pathname stream) returns the filename of a stream
(the pathname that was used to open it). SB-SYS:FD-STREAM-FD is an
SBCL-specific function.

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2

Gmane