Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!linac!att!cbnewsm!cbnewsk!ech From: ech@cbnewsk.att.com (ned.horvath) Newsgroups: comp.sys.mac.programmer Subject: Re: THINK C stdio vs Mac io Message-ID: <1991May30.150528.11958@cbnewsk.att.com> Date: 30 May 91 15:05:28 GMT References: <1991May29.143724.14855@cs.fau.edu> Organization: AT&T Bell Laboratories Lines: 31 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