octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

File descriptor indeed not always available? (was: Re: How do I pass a f


From: Olaf Till
Subject: File descriptor indeed not always available? (was: Re: How do I pass a file pointer to my octfile?)
Date: Thu, 23 Sep 2010 14:08:26 +0200
User-agent: Mutt/1.5.18 (2008-05-17)

On Wed, Sep 22, 2010 at 08:37:59PM -0400, John W. Eaton wrote:
> So you can convert a double precision file ID value to an
> octave_stream object (assuming there is an open stream that
> corresponds to that file ID).  From that, you can convert it to a
> pointer to a std::ostream (or std::istream) object.  There is no
> direct conversion from that to a C FILE pointer. -- the C++
> std::{i,o,io}stream objects might not actually be based directly on C
> FILE pointers.  For example, if you open a stream with
> 
>   fid = fopen ("foo.gz", "wz");
> 
> you are using zlib functions via a std::ostream object that wraps a
> gzFile object, and that doesn't provide a way to get at the underlying
> file descriptor or a FILE pointer.

I was not aware of this. Of corse there is the problem that Octaves
file IDs are supposed to be identical to the corresponding file
descriptors of the system. But I see that in the latest sources
do_stream_open() in file-io.cc now uses gzdopen() instead of gzopen()
and passes the file descriptor to octave_zstdiostream::create. At the
moment, c_zfile_ptr_buf::file_number() in c-file-ptr-stream.h still
returns -1 and

fopen ("foo.gz", "wz")

will return -1 in current Octave.

But surely you are just about to change this?

Olaf


reply via email to

[Prev in Thread] Current Thread [Next in Thread]