lim@iris.ucdavis.edu (Lloyd Lim) (02/17/89)
I realize this a rather basic question, but I never ventured into this area before. Please bear with me. I need to get information about a file (using PBGetFInfo) given a handle to a resource in that file. OK, so I do a HomeResFile which gives me the path reference number, then a GetVRefNum which gives me the volume reference number. Then I get stuck. PBGetFInfo likes file names or directory indexes. So I suppose I have to go through the indexes until I hit the correct file. But how do I know when it hits the correct file? The only thing I have is the path reference number to compare against the one that's returned. But the call only returns the first path it finds. So I guess I have to go through the FCB chain to find the file number to compare against the file number returned by PBGetFInfo. Do I really have to do all this or am I missing something? I realize that with HFS I could do a PBGetFCBInfo to get the file name and simply do a PBGetFInfo. However, I would also like this to work on 64K ROMS. If I really have to do what I outlined above then I might just forget about the old ROMS. My God! What did I just say! I started with an original 128K upgraded to 512K upgraded to 512KE upgraded to Plus. Someone, say it ain't so hard! +++ Lloyd Lim Internet: lim@iris.ucdavis.edu Compuserve: 72647,660 US Mail: 146 Lysle Leach Hall, U.C. Davis, Davis, CA 95616
tim@hoptoad.uucp (Tim Maroney) (02/18/89)
In article <3687@ucdavis.ucdavis.edu> lim@iris.ucdavis.edu (Lloyd Lim) writes: >I realize this a rather basic question, but I never ventured into this area >before. Please bear with me. Actually, I don't think it's so basic. This whole area of the OS is weird. >I need to get information about a file (using PBGetFInfo) given a handle to >a resource in that file. OK, so I do a HomeResFile which gives me the path >reference number, then a GetVRefNum which gives me the volume reference >number. > >Then I get stuck. PBGetFInfo likes file names or directory indexes. >I realize that with HFS I could do a PBGetFCBInfo to get the file name and >simply do a PBGetFInfo. However, I would also like this to work on 64K ROMS. These days, I would forget old ROMs. There are a miniscule fraction of the installed base; the Mac didn't start selling well until the Mac Plus. Still, if you do want to be compatible, you have the advantage that the old ROM OS is frozen, so you can get away with certain tricks that wouldn't be safe on today's systems. One such trick is looking directly in the FCB table. The file reference number is a byte offset into the table for the FCB you want. Add it to FCBSPtr (you may need to add another two bytes to bypass the length word, I'm not sure). Then you get the FCB structure documented in the old File Manager chapter, which contains the file number you need. And of course, you should *only* do this if you find that HFS is not installed (which isn't the same as checking for old ROMs; you can run the old RAM-based HFS on old ROM systems). Otherwise, use PBGetFCBInfo. -- Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim These are not my opinions, those of my ex-employers, my old schools, my relatives, my friends, or really any rational person whatsoever.