mnkonar@gorby.SRC.Honeywell.COM (Murat N. Konar) (02/28/89)
I am writing an INIT/cdev combo where the cdev and an INIT installed patch need access to the INIT file to read resources. Short of hardcoding the file name, how can I get the name of my INIT file from during INIT time for use later? Getting the file number is easy, but how do I use that number to re-open the file from inside a patch or cdev? I can't find any file opening routines that take this number as an argument, nor can I find any routines that take this number as an argument and return the name of the file. I know this must be possible since a number of cdevs seem to do this. Thanks in advance, _____________________________________________________________________ Have a day. :^| Murat N. Konar Honeywell Systems & Research Center, Camden, MN mnkonar@SRC.honeywell.com (internet) {umn-cs,ems,bthpyd}!srcsip!mnkonar (UUCP)
dwb@Apple.COM (David W. Berry) (03/01/89)
In article <17812@srcsip.UUCP> mnkonar@srcsip.UUCP (Murat N. Konar) writes: > >I am writing an INIT/cdev combo where the cdev and an INIT >installed patch need access to the INIT file to read >resources. Short of hardcoding the file name, how can I >get the name of my INIT file from during INIT time for >use later? Getting the file number is easy, but how >do I use that number to re-open the file from inside a >patch or cdev? I can't find any file opening routines >that take this number as an argument, nor can I find any >routines that take this number as an argument and return >the name of the file. I know this must be possible since >a number of cdevs seem to do this. The following code (completely untested and written off the top of my head) should do what you want. The code should also work for applications if executed immediately upon entry, ie., before the application opens any additional resource files. You'd have better luck in applications if you replaced the call to CurResFile with CurApRefNum. CurApRefNum is a short at 0x900. OSErr GetMyFileInfo(short *myRefNum, char *name) { FCBPBRec pb; pb.ioNamePtr = name; pb.ioVRefNum = 0; pb.ioRefNum = CurResFile(); /* get the refNum of the INIT file */ pb.ioFCBIndx = 0; PBGetFCBInfo(&pb, false); *myRefNum = pb.ioVRefNum; return pb.ioResult; } Opinions: MINE, ALL MINE! (greedy evil chuckle) David W. Berry (A/UX Toolbox Engineer) apple!dwb@sun.com dwb@apple.com 973-5168@408.MaBell