[comp.sys.apple2] Q: Orca/C and stat.h

bkahn@archive.webo.dg.com (Bruce Kahn) (09/07/90)

  Im trying to port some programs from the MessDOS and Un*x worlds but some
of them include the file <sys/stat.h> and utilize the structure stat.  The
structure is used for calls like:
	struct stat statbuf;
	char *iomod;
		...
	iomode = (stat(outfilename, &statbuf) == 0) ? "r+b" : "wb";

where iomode is then used in the fopen() routine to set the I/O mode for
file access.  I cant find any references to this structure in any of the
Orca/C or APW include files.  Is there an equivalent structure and call 
for the APW and Orca/C environments?  Should I bite the bullet and just
kludge the code (forcing iomode to a specific mode)?


--
                                            Bruce (bkahn@archive.rtp.dg.com or
                                                   kahn@adam.dg.com)
  
  Standard disclaimers apply, except where prohibited by law...

wilner@motcid.UUCP (Corey S. Wilner) (09/11/90)

bkahn@archive.webo.dg.com (Bruce Kahn) writes:


>  Im trying to port some programs from the MessDOS and Un*x worlds but some
>of them include the file <sys/stat.h> and utilize the structure stat.  The
>structure is used for calls like:
>	struct stat statbuf;
>	char *iomod;
>		...
>	iomode = (stat(outfilename, &statbuf) == 0) ? "r+b" : "wb";

>where iomode is then used in the fopen() routine to set the I/O mode for
>file access.  I cant find any references to this structure in any of the
>Orca/C or APW include files.  Is there an equivalent structure and call 
>for the APW and Orca/C environments?  Should I bite the bullet and just
>kludge the code (forcing iomode to a specific mode)?


>--
>                                            Bruce (bkahn@archive.rtp.dg.com or
>                                                   kahn@adam.dg.com)
>  
>  Standard disclaimers apply, except where prohibited by law...

The second edition of K & R's C Programming Language has a complete(?) 
description beginning on page 180.

***********************************************
Corey S. Wilner    |  Give me a jingle:
Motorola Cellular  |   ..!uunet!motcid!wilner
708-632-7206       |
***********************************************
If after 30 minutes of a card game you don't
know who the rube is, you are!

McAfee's Law of Physical Material Balance:
Matter can be neither created nor destroyed.
However, it can be lost!

gwyn@smoke.BRL.MIL (Doug Gwyn) (09/12/90)

In article <923@dg.dg.com> bkahn@archive.webo.dg.com (Bruce Kahn) writes:
>	iomode = (stat(outfilename, &statbuf) == 0) ? "r+b" : "wb";

<sys/stat.h>, struct stat, and stat() all do not exist in most non-POSIX
(non-UNIX-like) systems.  Rather than giving up, why not rewrite the code
to do what was intended (which this code doesn't do right anyway), using
standard C facilities.