Article View: comp.sys.mac
Article #18295Re: HFS Questions
From: Larry Rosenstein
Date: Thu, 20 Aug 1987 20:01
Date: Thu, 20 Aug 1987 20:01
82 lines
4310 bytes
4310 bytes
In article <1071@vu-vlsi.UUCP> kresch@vu-vlsi.UUCP (Ed Kresch) writes:
>
>1. How can one determine the vRefNum of the application that is currently
> running, from within the application?
The current volume (as returned by GetVol) will indicate the folder
containing the application. This will be a wdRefnum if the application is
inside a folder.
>2. If one creates temporary files, should they be in the same folder as
> the application, in the system folder, or somewhere else? Is there
> a standard for this, or is it the application's choice?
It depends.
Applications can be launched from a server, so if you place it in the same
folder as the app, it might end up on a server. The System Folder is
guaranteed to be a local volume. On the other hand, the disk containing the
System Folder might be very full if the user is running a floppy-based
system. (If you wanted to get sophisticated, you would try several volumes
until you find one that has enough disk space.)
If you do place the file in the same folder as the application, make sure to
give it a unique name, in case more than 1 user tries to run the application
at the same time.
>3. How do you store an absolute reference to a file: one that can be
> saved in a datafile and loaded the next time the application is run
> when different disks may be in each drive, new folders may have been
> created, etc?
One possibility is to store the full pathname to a file. The problem is
that the user can change the name of any folder in the path very easily.
(Also note that a full pathname might be longer than 255 characters, which
would prevent you from passing it to HFS all at once.)
You can get around this by storing the dirID of the folder containing the
file, along with the name of the volume and name of the file. dirIDs are
unique on a volume (until it is reformatted). The only problem is that some
servers don't guarantee that dirIDs are constant each time you mount the
server. (They create unique dirIDs while you have the server volume
mounted, but not if you unmount & remount the server.)
Since you have to store a volume and file name anyway, there will always be
the possibility that the user will change the name, and your program won't
be able to find the file. In this case, you should bring up a Standard File
dialog, allow the user to find the file for you, and save its new location.
>4. How do you find out the vRefNum of the system folder? Is it BootDrive,
> or is BootDrive a reference to the root directory of the startup volume?
BootDrive does not always contain the actual wdRefnum. Tech Note 77 contain
code for finding out the wdRefnum of the System Folder.
>5. How does one determine if the vRefNum returned by SFGetFile or
> GetAppFiles is a volume reference number or a working directory reference
> number?
I think you can use PBGetCatInfo to find out. If you get the info for the
vRefnum, you can check to see if the field ioDrDirID is 2, which indicates
the root of a volume.
>6. When an application starts up, are there any working directories?
Yes, there will be at least a working directory for the folder containing
the application. (I don't know what happens if the application is at the
root.)
>7. How does Launch know which volume to launch the application from?
Launch uses the current volume. The code for ExitToShell does a SetVol
back to BootDrive before launching the Finder.
--
Larry Rosenstein
Object Specialist
Apple Computer
AppleLink: Rosenstein1
UUCP: {sun, voder, nsc, mtxinu, dual}!apple!lsr
CSNET: lsr@Apple.com
Technical Details
Message-ID:
<1560@apple.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!rutgers!labrea!decwrl!pyramid!voder!apple!lsrReferences:
<1071@vu-vlsi.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!uunet!seismo!rutgers!labrea!decwrl!pyramid!voder!apple!lsr From: lsr@apple.UUCP (Larry Rosenstein) Newsgroups: comp.sys.mac Subject: Re: HFS Questions Message-ID: <1560@apple.UUCP> Date: Thu, 20-Aug-87 16:01:57 EDT Article-I.D.: apple.1560 Posted: Thu Aug 20 16:01:57 1987 Date-Received: Sat, 22-Aug-87 12:11:34 EDT References: <1071@vu-vlsi.UUCP> Reply-To: lsr@apple.UUCP (Larry Rosenstein) Distribution: na Organization: Advanced Technology Group, Apple Computer Lines: 82 Keywords: HFS, Launching Applications