[comp.sys.mac] SFGetFile question

gardner@prls.UUCP (Robert Gardner) (12/19/87)

I am trying to call SFPGetFile twice in a row to get two input
files from the user. On the second call I want to filter out
the file they chose the first time. I have not been able to find
a way to do this. If anyone has any ideas I would appreciate
help ASAP.

My first attempt was to save the file name and vRefNum from the
first call and then check those fields in the fileParam block passed
to the filter for a match. Unfortunately, the ioVRefNum passed to
the filter is ALWAYS -1 (at least under HFS). I can't figure out
any way to get from the information in the fileParam block to
a vRefNum to compare it with. I also tried doing a PBGetFInfo call
after the first call to SFPGetFile and saving some info there for
comparison, but there are so many ways to specify a volume that
I couldn't figure out how to do it the same way that is needed
for the filter. The volume information doesn't seem to be changed
in PBGetFInfo from what you specify.

Any help would be greatly appreciated.

Robert Gardner

darin@apple.UUCP (Darin Adler) (12/19/87)

In article <8119@prls.UUCP> gardner@prls.UUCP (Robert Gardner) writes:
> I am trying to call SFPGetFile twice in a row to get two input
> files from the user. On the second call I want to filter out
> the file they chose the first time. I have not been able to find
> a way to do this. If anyone has any ideas I would appreciate
> help ASAP.
> 
> My first attempt was to save the file name and vRefNum from the
> first call and then check those fields in the fileParam block passed
> to the filter for a match. Unfortunately, the ioVRefNum passed to
> the filter is ALWAYS -1 (at least under HFS). I can't figure out
> any way to get from the information in the fileParam block to
> a vRefNum to compare it with.

You are on the right track.

The problem that you have here is that both PBGetCatInfo (which is called
automatically by Standard File) and PBGetFInfo return both a vRefNum and
a dirID. The reason that the ioVRefNum is always -1, is that the vRefNum
of the disk in question IS -1. The vRefNum that you get from Standard
File in the reply is a WDRefNum. To find out the dirID for this WDRefNum
you can call PBGetWDInfo. Then, you can compare the file name, the
vRefNum *and* the dirID.
-- 
Darin Adler, Apple Computer                          AppleLink:Adler4
UUCP: {sun,voder,nsc,mtxinu,dual}!apple!darin  CSNET: darin@Apple.com

tom@iconsys.UUCP (Tom Kimpton) (12/23/87)

In article <8119@prls.UUCP> gardner@prls.UUCP (Robert Gardner) writes:
>I am trying to call SFPGetFile twice in a row to get two input
>files from the user. On the second call I want to filter out
>the file they chose the first time.
>

Tim Maroney (I believe) posted a really good routine last week called
GetVolDir(vRef,volptr,dirptr) that takes a vRefNum, and returns,
through the pointers, the volume and directory numbers.  Using these
in your filter, with the name, and the passed-in paramblock, should
do what you want.

Hope that helps.

-- 
Tom Kimpton		    {ihnp4,uunet}!iconsys!tom
Icon International, Inc.    {ihnp4,psivax}!nrcvax!nrc-ut!iconsys!tom
Orem, Utah 84058	    ARPANET: icon%byuadam.bitnet@wiscvm.wisc.edu
(801) 225-6888		    BITNET: icon%byuadam.bitnet