[comp.sys.mac.programmer] Keeping track of files

jamesm@sco.COM (James M. Moore) (09/16/89)

I'm writing an application where I'd like to keep track of file locations
after a reboot.  I assume that keeping track of the volume reference
number returned from SFGetFile isn't enough, as it's subject to change
across reboots.  What should I use in addition to the file name?
-- 
James Moore                            | You will face many tests in life.
Santa Cruz Operation UNIX Tech Support |
jamesm@sco.com                         | This is not one of them.

mcelhoe@cory.Berkeley.EDU (Glenn McElhoe) (09/28/89)

In article <5875@viscous.sco.COM> jamesm@sco.COM (James M. Moore) writes:
>
>I'm writing an application where I'd like to keep track of file locations
>after a reboot.  I assume that keeping track of the volume reference
>number returned from SFGetFile isn't enough, as it's subject to change
>across reboots.  What should I use in addition to the file name?

The 'vrefnum' that you get from SFGetFile is actually (under HFS) a
working directory reference number, and will change when the working
directory is closed (e.g. when you turn your machine off).  Anyway, what
you need to save are the real volume reference number, the DirID, and the
name of the file.  Of course this will all change under System 7.0, but then
it will be more 'convenient' because you will only have three formats to
be compatible with :-)

The way to get these little gems is to use PBOpenWD to get the WD from the
volume and dirID, and PBGetWDInfo to go the other way.

Hope that helps,

--
Glenn McElhoe
(mcelhoe@cory.Berkeley.EDU)

chewy@apple.com (Paul Snively) (09/28/89)

In article <17768@pasteur.Berkeley.EDU> mcelhoe@cory.Berkeley.EDU (Glenn 
McElhoe) writes:
> In article <5875@viscous.sco.COM> jamesm@sco.COM (James M. Moore) writes:
> >
> >I'm writing an application where I'd like to keep track of file 
locations
> >after a reboot.  I assume that keeping track of the volume reference
> >number returned from SFGetFile isn't enough, as it's subject to change
> >across reboots.  What should I use in addition to the file name?
> 
> The 'vrefnum' that you get from SFGetFile is actually (under HFS) a
> working directory reference number, and will change when the working
> directory is closed (e.g. when you turn your machine off).  Anyway, what
> you need to save are the real volume reference number, the DirID, and the
> name of the file.

Oops--wrongo.  The vRefNum for a volume isn't constant, either; it depends 
upon when the file system "sees" it.  What you REALLY need are the NAME of 
the volume (ack!  pfffft!), the dirID, and the name of the file.

The "how you get them" stuff still applies, though.

__________________________________________________________________________
Just because I work for Apple Computer, Inc. doesn't mean that they 
believe what I believe or vice-versa.
__________________________________________________________________________