Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!udel!haven!mimsy!mojo!russotto From: russotto@eng.umd.edu (Matthew T. Russotto) Newsgroups: comp.sys.mac.programmer Subject: Re: Problem with GetResource in a cdev Message-ID: <1990Dec2.072916.23902@eng.umd.edu> Date: 2 Dec 90 07:29:16 GMT References: <48578@eerie.acsu.Buffalo.EDU> Sender: news@eng.umd.edu (C-News) Organization: College of Engineering, Maryversity of Uniland, College Park Lines: 40 In article <48578@eerie.acsu.Buffalo.EDU> volaski@acsu.buffalo.edu (Maurice Volaski) writes: >In a cdev, I open the resource fork of a file and attempt to read one of >its resources. However, GetResource returns a nil handle indicating it >is unable to find the resources of the specified type. >ResError and MemError both return 0. > >oldResFile=CurResFile(); /*save reference number to cdev's*/ /*resources*/ >*resNum=HOpenResFile(vRefNum,dirID,fileName,fsRdWrPerm); /*open my file's > /*resource fork*/ >tempRes=GetResource('EXL ',-4048); /* GetResource succeeds here*/ >UseResFile(oldResFile); /* make cdev resource file current*/ >tempRes=GetResource('EXL ',-4048); /* PROBLEM: GetResource fails*/ >num=CountResources('EXL '); /* CountResources succeeds*/ >tempRes=GetIndResource('EXL ',1); /*GetIndResouces succeeds*/ > >Even though the file's resources are not current, GetResource should iterate >through the list of open resource files and find the resource. Interestingly, >CountResources and GetIndResource both succeed. Also, GetResource does >succeed when the file's resources are current. > >Anyone have a clue as to why GetResource fails in this particular instance? > >Maurice Volaski Believe it or not, all of the above is documented, correct, behavior. ResErr is 0 because there are no resources of type 'EXL ' in any resource file searched by GetResource-- this is a long-standing documented 'feature' of GetResource. GetResource does not search files opened after the current resource file. This is also documented, correct behavior. CountResources and GetIndResource don't respect the current resource file, and instead search all open resource files. This is also documented, correct behavior. Look at Inside Mac Volume I, pages 118-119. -- Matthew T. Russotto russotto@eng.umd.edu russotto@wam.umd.edu .sig under construction, like the rest of this campus.