[net.micro.mac] Finder info

jimp@dartvax.UUCP (Jim Perry) (05/02/85)

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