Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!unix.cis.pitt.edu!dsinc!netnews.upenn.edu!msuinfo!midway!quads.uchicago.edu!rtp1 From: rtp1@quads.uchicago.edu (raymond thomas pierrehumbert) Newsgroups: comp.sys.mac.programmer Subject: Summary-- SFPutFile with fopen(), how? Message-ID: <1990Nov7.182122.6620@midway.uchicago.edu> Date: 7 Nov 90 18:21:22 GMT Sender: news@midway.uchicago.edu (News Administrator) Organization: University of Chicago Lines: 46 I have received many interesting replies on the question of how to use the SFReply record (say, theReply) with standard c io if you have existing code and don't want to replace all the io with Mac calls. There were a number of interesting suggestions for interesting and possible modifications to the code for fopen, but the solution that worked best for me was one that didn't involve any modifications of this sort. Suppose you have theReply from calling SFPutFile (or SFGetFile). Then, you can open the file you want in the volume you want by just doing a SetVol, and a PtoCstr conversion. For an existing file: char *buf FILE *myFile pStrCopy((macSFReply->fName),buf);PtoCstr(buf); SetVol(0L,macSFReply->vRefNum); myFile = fopen(buf,"ab"); (This example is for appending binary data to a file). Here, PStrCopy is a routine for making a copy of a Pascal string referenced by its pointer (not its stringhandle). For a new file, everything works the same, except you need to do a Create first to make the Mac file with the correct creator type and document type. Note, that fopen must be specified with one of the "append" permissions. "w" and "wb" seem to wipe out the file you Create'd, and replace it with a file of its own creation. Note also, that you need to keep track of the vRefNum if you ever want to reopen the file later, since the current volume might have been changed in the interim. This all worked nicely, except that for me, the fopens are all in a big library I don't want to mess with, and so I can't easily change the access permissions for new files to appends from "wb". So, I can make the file where I want, but lose the creator and type information. So my next query: Is there an easy way to reset the creator and type of an existing file ex post facto? I know the answer is in Inside Macintosh, but then again, the answer to all the questions of the Universe is in the I Ching, so I could just as well go there. So what I need is simple and less obscure advice. (please reply by email to rtp1@midway.uchicago.edu)