delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/04/05:31:02

From: eyal DOT ben-david AT aks DOT com
To: S2200253 AT nickel DOT laurentian DOT ca
cc: djgpp AT delorie DOT com
Message-ID: <422564AC.003862A6.00@aks.com>
Date: Wed, 4 Jun 1997 12:28:01 +0200
Subject: Re: fstat & C++ iostreams
Mime-Version: 1.0



> To call the function fstat will I have to re-open the given file
> using the "old" C FILE method or is there a way to do so with
> the already open file stream?
1. you can do in with 'stat' and supplying a filename.

2. if the file is already open there's a better way:
     remember that any i/ofstream object has a pointer to
     a 'filebuf' object (the one that does the real job)
     you access this function with rdbuf().

     Example:
            ofstream   fout("file.ext");
             int  fd = fout.rdbuf()->fd();      // returns EOF if file
isn't open.

             // now you can use all the C functions that take file
descriptor.
             fstat(fd, .....);



Eyal.


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019