tim@cmu-cs-k.ARPA (Tim Maroney) (03/19/85)
I spent today finding and fixing a bug in an Appletalk file transfer program. The information may be of interest to any developer who is using the SetFInfo call to set the finder information on a new file. The File Manager Programmer's Guide shows the "fdFlags" field of the "FInfo" (finder information) record of each file. It's a 16-bit word in which each bit has a quasi-Boolean significance. Unfortunately, only two of the bits are documented! I have found out the hard way the significance of bit 9. It means "file icon location is known". If it is clear, then the Finder will figure out a blank place to put the icon into before displaying the window/folder containing the file, and it will set the bit and the "fdLocation" in the process. If bit 9 is already set, the Finder assumes that the point in the "fdLocation" field is the place to put the icon, and it does not look for a new location. This is important to know if you are copying files from one disk to another (for instance, by a file transfer over Appletalk) and are trying to preserve the finder information by using SetFInfo. Obviously you don't want to copy the fdLocation, because that point may already be taken up on the target disk, and overlaps are gross. But using the location returned from the "Create" call on the new file will not work, because "Create" just zeroes out the location and leaves bit 9 clear. If you copy the fdFlags word from the old file, you will probably be setting bit 9 of the new file's fdFlags word, since the location of the old file was probably known. So instead you should clear bit 9 before putting it into the new file's fdFlags word. Otherwise your icon will always turn up at (0,0)! Clearing bit 9 can be done by a 16-bit AND with $FEFF (0xfeff in the C language -- I gotta use Lisa Pascal). In the latest version of the Lisa Pascal compiler, this can be done directly, but I don't think that's been released yet. Here's a function Mark Sherman wrote to use the built-in 32-bit integer bitwise AND function to AND two 16-bit integers. FUNCTION CBitAnd(L,R:INTEGER): INTEGER; VAR TempL, TempR: LongInt; BEGIN TempL := L; TempR := R; CBitAnd := LoWord(BitAnd(TempL,TempR)); END; I hope this helps someone. Most of us have better things to do than waste days at a time chasing undocumented features. -=- Tim Maroney, Carnegie-Mellon University, Networking ARPA: Tim.Maroney@CMU-CS-K uucp: seismo!cmu-cs-k!tim CompuServe: 74176,1360 audio: shout "Hey, Tim!"