[comp.sys.ibm.pc] File Handles in Turbo C

dkrause@orion.cf.uci.edu (Doug Krause) (07/10/89)

After "fopen"ing a file, how can I get a file handle?  (I want to use
the function getftime.)

Douglas Krause                     CA Prop i:  Ban Gummie Bears(tm)!
--------------------------------------------------------------------
University of California, Irvine   ARPANET: dkrause@orion.cf.uci.edu
Welcome to Irvine, Yuppieland USA  BITNET: DJKrause@ucivmsa

cs75jmc@unccvax.UUCP (john m covington) (07/10/89)

In article <2214@orion.cf.uci.edu>, dkrause@orion.cf.uci.edu (Doug Krause) writes:
> 
> After "fopen"ing a file, how can I get a file handle?  (I want to use
> the function getftime.)
> 
> Douglas Krause                     CA Prop i:  Ban Gummie Bears(tm)!

In most C systems, you would use the fileno() function (on some systems
it may be a macro).  e.g.:

	FILE *fa;
	int fd;
	
	...

	fd = fileno(fa);

would put the file handle in fd.  Of course in the function call
to getftime you could just put the fileno function in the
argument list.  I'm not familiar with getftime but it might
look like this:
	getftime(fileno(fa),&result);

dold@mitisft.Convergent.COM (Clarence Dold) (07/10/89)

in article <2214@orion.cf.uci.edu>, dkrause@orion.cf.uci.edu (Doug Krause) says:

> After "fopen"ing a file, how can I get a file handle?  (I want to use
> the function getftime.)

#include <stdio.h>
int fileno(stream);
FILE *stream;

fileno returns the file handle.
There is no error return.
Results are undefined if 'stream' does not specify an open file.

fileno is implemented as a macro.
-- 
---
Clarence A Dold - dold@tsmiti.Convergent.COM		(408) 434-5293
		...pyramid!ctnews!tsmiti!dold
		P.O.Box 6685, San Jose, CA 95150-6685	MS#10-007

bobc@attctc.DALLAS.TX.US (Bob Calbridge) (07/11/89)

In article <2214@orion.cf.uci.edu>, dkrause@orion.cf.uci.edu (Doug Krause) writes:
> 
> After "fopen"ing a file, how can I get a file handle?  (I want to use
> the function getftime.)

FINALLY!!!  A question I know the answer to.  Use the fileno() function.
example:

	(int) handle = fileno ((FILE *) internal_name);

(actually I had to use this just the other day)

Bob
-- 
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
=             I know it's petty..........                                     =
-                  But I have to justify my salary!                           -
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=