bwp@utcs.UUCP (Bruce Pinn) (06/24/85)
How does the finder generate the ID numbers for each item in the FCMT resource of the Desktop? I remember a posting on the net (a while back) that gave the hashing algorithm. Could someone please repost it or mail it to me? Thanks Bruce Pinn (...{decvax,ihnp4}!utzoo!utcs!utgumby!bwp)
supp@sphinx.UChicago.UUCP (Steve Upp) (06/27/85)
>How does the finder generate the ID numbers for each item in the FCMT >resource of the Desktop? I remember a posting on the net (a while back) >that gave the hashing algorithm. Could someone please repost it or mail >it to me? Here is (the original posting) of some information on the FCMT resource found in the desktop file. I've used this in my application and it works fine for both the 1.1g and 4.1 versions of the Finder. Because this information is not documented (and I get the feeling that even if it were) Apple can change the way that the code is generated with any new version of the Finder. As Jim points out this is not a very good algorythm. >>From: jimp@dartvax.UUCP (Jim Perry) >>Newsgroups: net.micro.mac >>Subject: Finder info (FCMT's) >>Message-ID: <3008@dartvax.UUCP> >>Date: Thu, 2-May-85 12:27:00 CDT >>Date-Received: Wed, 8-May-85 09:17:48 CDT >>Distribution: net >>Organization: Dartmouth College, Hanover, NH >>Lines: 32 >> >>The Finder's information strings containing the text entered in the Get Info >>window are stored as FCMT (=STR ) resources in the volume's DeskTop file. >>The resource ID is computed from the filename as a 15-bit hash code (always >>negative), with no provision for handling collisions. The specific hashing >>algorithm is, >> >> result <- 0 >> for each byte in the name (L->R), >> result <- ror.w(result xor byte, 1) >> if no carry (result positive), negate result >> >>In Lisa Pascal (post-3.0; if using toolbox bit ops, watch for integer->>longint >>sign extension), >> >> var result,i: integer; b: boolean; name: str255; >> ... >> result := 0; >> for i := 1 to length(name) do begin >> result := bxor(result, ord(name[i])); >> b := odd(result); (* would rotate produce carry? *) >> result := bsr(result,1); (* long rotate doesn't help *) >> if b then result := bor(result,$8000) (* simulate carry *) >> else result := -result; (* if no carry, negate *) >> end; >> >>Perhaps the reason Apple hasn't spread this around more is that it's not >>a very good scheme: multiple unrelated names can map into the same FCMT -- >>most unfriendly. Why not just use named resources? Anyway, anybody using >>this information for e.g. file transfer would do well do plan ahead for >>incompatible Finder changes. >> >>Jim Perry, Dartmouth College jimp@dartvax -- Steve Upp University of Chicago Computation Center ARPA: Staff.Steve%UChicago.mailnet@Mit-Multics.arpa Bitnet: supp%sphinx@UChicago.bitnet Mailnet: Staff.Steve@UChicago.mailnet UUCP: ...!ihnp4!gargoyle!sphinx!supp