Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cwjcc!ukma!rutgers!apple!well!odawa From: odawa@well.UUCP (Michael Odawa) Newsgroups: comp.sys.mac.programmer Subject: Re: list of files Message-ID: <10605@well.UUCP> Date: 4 Feb 89 20:30:32 GMT References: Reply-To: odawa@well.UUCP (Michael Odawa) Organization: Simple Software, Mill Valley, CA Lines: 69 In article wiechman@athos.rutgers.edu (NightMeower) writes: > >...What I'd like to do is using SFGetfile >create a list of files to form a queue which could then be saved and >read back in at a later time and processed....It would appear that >just having the vrefnum and fname is not enough. So I have been >including the dirid so that I can open a working directory. However, >all or some of these numbers appear to be different when I try to >process them at a later time. Ideas? >At this point, I am starting to think that I will need to save a whole >path name for each file. Don't save the whole path name. The file name and DirID are invariant, unless the user changes them intentionally. The vRefNum is dynamic; it's assigned when the working directory is opened. So, using SFGetFile, you would save the fName, convert the vRefNum to a DirID: with WDPB do begin ioNamePtr := nil; ioVRefNum := vRefNum; ioWDIndex := 0; ioWDProcID := 0; end; { with WDPB.. } if PBGetWDInfo(@WDPB, false) = noErr then DirID: := WDPB.ioWDDirID; But DirIDs are valid only within a particular volume, so you also need the volume name. You get this with: s := ''; with PB do begin ioNamePtr := @s iovRefNum := vRefNum; ioVolIndex := 0; end; { with PB.. } FSErr := PBHGetVInfo(@PB, false); if FSErr = noErr then VolName := s; Save the VolName and DirID with the fName. Then, when you want to work out your list, you have to: vRefNum := 0; SetVol(@VolName, 0); with WDPB do begin ioNamePtr := nil; ioVRefNum := 0; ioWDDirID := DirID; ioWDProcID := FinderSig; FSErr := PBOpenWD(@WDPB, false); if FSErr = noErr then vRefNum := ioVRefNum; end; { with WDPB.. } SetVol(nil, vRefNum); Now you should be back where you want to be; if the file fName isn't present, it's because the user has moved it. Notify him, and let him find it with SFGetFile. Oh, and why shouldn't we save whole path names? (a) Because they can be indefinitely long. (b) Because the above scheme will work even if the user changes the folders' names, or rearranges the nesting order of folders within his disk. Michael Odawa Simple Software odawa@well.UUCP