[comp.sys.mac.programmer] THINK C stdio vs Mac io

jboser@cs.fau.edu (Jeff Boser) (05/29/91)

I have written a utility using stdio in Think C, and now need to add
some functionality.  Is it possible to use stdio routines on files
opened or specified by the File Manager?  meaning, how can I use
StandardFile routines to specify a stdio file?

The Think C manual seems to contain no information on the subject,
not even a warning.


thanks in advance,

.....jeff
jboser@tuna.cs.fau.edu

-- 
"Make something an idiot can use, and only an idiot will use it." - RAH
Like a bible, maybe? - me

ech@cbnewsk.att.com (ned.horvath) (05/30/91)

From article <1991May29.143724.14855@cs.fau.edu>, by jboser@cs.fau.edu (Jeff Boser):

> ...Is it possible to use stdio routines on files
> opened or specified by the File Manager?  meaning, how can I use
> StandardFile routines to specify a stdio file?
> 
> The Think C manual seems to contain no information on the subject,
> not even a warning.

'opened by' is hard; go take a look at the fopen.c and iomisc.c to try
to figure out how to hand off a Mac file refNum to stdio FILE.

If you want to somehow do an fopen given an SFReply, that's fairly easy:
	short currVRefNum;	/* for saving current directory */
	SFReply sfr;
	FILE * fp;

	SFGetFile (...&sfr...);	/* or SFPutFile; be sure to use O_CREAT */
	if (sfr.good) {
		GetVol (NULL, &currVRefNum);
		SetVol (NULL, sfr.vRefNum);
		PtoCstr (sfr.fName);
		fp = fopen (sfr.fName, mode);
		SetVol (NULL, currVRefNum);
	} else
		fp = NULL;

This ought to be on the C.S.M.P FAQ list...
-- 
=Ned Horvath=
ehorvath@attmail.com

peterc@sugar.hackercorp.com (Peter Creath) (06/05/91)

Wow, my news system actually responded to the right article this time!
 
Anyway, how do I handle a LARGE text buffer (ie: for a term program)
where the only editing will occur on-screen, and the scrollback buffer
is static, but viewable?  TEdit is too slow.  I tried TEInsert (data
jumps across) and TEKey (too damn slow).  Is there anything else I
should try?

--