tj@oahu.cs.ucla.edu (Tom Johnson) (01/03/90)
Can somebody please help??? The following is a small piece of code in Think C 4.0. Why can't I get it to work? #define SFSaveDisk 0x214 /*low memory global*/ myCInfoPBRec myInfoRec; Str255 directoryName; myInfoRec.dirInfo.ioNamePtr = directoryName; myInfoRec.dirInfo.ioDrDirID=MyCurDir; /* from SFGetFile as in DTS SC 018 */ myInfoRec.dirInfo.ioFDirIndex = -1; /*directories only*/ myInfoRec.dirInfo.ioVRefNum =(-*(short *)SFSaveDisk); error=PBGetCatInfo(&myInfoRec,false); if (error != noErr) SysBeep(10); /*I was making a few changes here, but even when they were removed, the problem didn't go away*/ error=PBSetCatInfo(&myInfoRec,false); if (error != noErr) Debugger(); When I run this code, no error is detected on the PBSetCatInfo call and the CInfoPBRec appears to be correctly filled in, but PBSetCatInfo returns error=FFD5 a fnfError (file not found). Does anybody have any idea why? This has been driving me crazy for hours!! Thanks. Tom -- Tom Johnson UCLA Computer Science Department 3413 Boelter Hall, Los Angeles CA 90024 (213)825-6952 UUCP: {uunet,rutgers,ucbvax}!cs.ucla.edu!tj Internet: tj@cs.ucla.edu
keith@Apple.COM (Keith Rollin) (01/03/90)
In article <30340@shemp.CS.UCLA.EDU> tj@oahu.cs.ucla.edu (Tom Johnson) writes: > > error=PBGetCatInfo(&myInfoRec,false); > if (error != noErr) SysBeep(10); >/*I was making a few changes here, but even when they were >removed, the problem didn't go away*/ > error=PBSetCatInfo(&myInfoRec,false); > if (error != noErr) Debugger(); > >When I run this code, no error is detected on the PBSetCatInfo call and >the CInfoPBRec appears to be correctly filled in, but PBSetCatInfo >returns error=FFD5 a fnfError (file not found). Does anybody have >any idea why? This has been driving me crazy for hours!! Tom, I think that what is happening is that your ioDirID field is being changed from MyCurID on the PBGetCatInfo call. Then, when you try the PBSetCatInfo call, you are using a DirID different from the original one. Or something like that. Maybe the field in question is ioVRefNum. At any rate, I remember having a similar problem not too long ago, and the solution was to re-initialize some fields that got changed after the PBGetCatInfo call. Or perhaps your ioFDirIndex field is being changed from -1 to 0, since you are getting a _file_ not found error. Sorry for being so fuzzy... -- ------------------------------------------------------------------------------ Keith Rollin --- Apple Computer, Inc. --- Developer Technical Support INTERNET: keith@apple.com UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith "Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions
tim@hoptoad.uucp (Tim Maroney) (01/03/90)
>In article <30340@shemp.CS.UCLA.EDU> tj@oahu.cs.ucla.edu (Tom Johnson) writes: >> error=PBGetCatInfo(&myInfoRec,false); >> if (error != noErr) SysBeep(10); >> [flags set, etc.] >> error=PBSetCatInfo(&myInfoRec,false); >> if (error != noErr) Debugger(); >> >>When I run this code, no error is detected on the PBSetCatInfo call and >>the CInfoPBRec appears to be correctly filled in, but PBSetCatInfo >>returns error=FFD5 a fnfError (file not found). Does anybody have >>any idea why? This has been driving me crazy for hours!! In article <37560@apple.Apple.COM> keith@Apple.COM (Keith Rollin) writes: >I think that what is happening is that your ioDirID field is being changed from >MyCurID on the PBGetCatInfo call. Then, when you try the PBSetCatInfo call, >you are using a DirID different from the original one. Yes. PBGetCatInfo changes the dirID it returns, apparently to the file ID. (Yet another place where this pointless feature is a pain in the ass.) It is necessary to save the dirID before calling PBGetCatInfo, then to reset the ioDirID field to this saved value before calling PBSetCatInfo. And of course, this is completely undocumented, unless you count the mysterious two-headed arrow before ioDirID in the description of the PBGetCatInfo routine. -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com "When errors are found in old research, the relevant theories are re-examined. When facts contradict theory, theory gets dumped. Is that why the NLP people are unwilling to research their facts?" -- Jerry Hollombe on sci.psychology
ech@cbnewsk.ATT.COM (ned.horvath) (01/09/90)
From article <30340@shemp.CS.UCLA.EDU>, by tj@oahu.cs.ucla.edu (Tom Johnson): ! Can somebody please help??? ! The following is a small piece of code in Think C 4.0. ! Why can't I get it to work? ! ! #define SFSaveDisk 0x214 /*low memory global*/ ! myCInfoPBRec myInfoRec; ! Str255 directoryName; ! ! ! myInfoRec.dirInfo.ioNamePtr = directoryName; ! myInfoRec.dirInfo.ioDrDirID=MyCurDir; /* from SFGetFile as in DTS SC 018 */ ! myInfoRec.dirInfo.ioFDirIndex = -1; /*directories only*/ ! myInfoRec.dirInfo.ioVRefNum =(-*(short *)SFSaveDisk); ! error=PBGetCatInfo(&myInfoRec,false); ! if (error != noErr) SysBeep(10); ! /*I was making a few changes here, but even when they were ! removed, the problem didn't go away*/ ! error=PBSetCatInfo(&myInfoRec,false); ! if (error != noErr) Debugger(); ! ! When I run this code, no error is detected on the PBSetCatInfo call and ! the CInfoPBRec appears to be correctly filled in, but PBSetCatInfo ! returns error=FFD5 a fnfError (file not found). Does anybody have ! any idea why? This has been driving me crazy for hours!! I assume you meant "no error is detected on the PBGetCatInfo." The problem is that the ioDrDirID field is interpreted by PBSetCatInfo as the dirID of the PARENT directory, whereas PBGetCatInfo accepted and set the dirID of MyCurDir. Thus, between the calls, set ioDrDirID from ioDrParID. And don't feel bad, that is far from clear in IM IV. =Ned Horvath=