FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

DISK I/O

Understand vRefNum's, wdRefNum's, etc.


Per request, here is a brief synopsis of some of the various ways in which directories and files are specified on the Mac. It's not meant to be a complete description, but perhaps it will shed some light, or spark discussion.

Volume Reference Number
* "Small" negative 16-bit integer (range: -1 to -16384?).
* Uniquely identifies a currently mounted volume.
* Every currently mounted volume has one.
* Assigned by the OS at the time the volume is mounted.
* Maintained in RAM by the OS.
* Valid until the volume is unmounted.
* Startup volume will probably have a volume ref. number of -1.

Drive Number
* Positive 16-bit integer.
* Uniquely identifies a connected physical drive.
* Every connected physical drive has one.
* Assigned by the OS at startup.
* Maintained in RAM by the OS.
* Valid until shutdown.
* 1 = Main floppy drive, 2 = Secondary floppy drive (if any).
* Probably the same at every startup, unless hardware config. changes.

Directory ID Number
* Positive 32-bit integer.
* Within a given volume, uniquely identifies a directory (folder).
* Every directory has one.
* Assigned by the OS at the time the directory is created.
* Maintained on disk, as part of the directory's information.
* Valid until the directory is deleted.
* Does not change if directory is renamed or moved (within the volume).
* 2 = Root directory, 1 = "Parent" of root directory.

Working Directory Reference Number
* "Large" negative 16-bit integer (range: -16385? to -32768).
* Uniquely identifies a directory among all directories on all currently mounted volumes.
* Often incorrectly called a "volume reference number" in much documentation (this is for historical reasons which we won't go into here).
* Root directories never have a Working Directory Reference Number.
* Other directories may have zero, one, or more than one WDRN.
* Assigned at the request of an application when it calls the Toolbox function OpenWD (some FutureBasic functions, such as FOLDER and FILES$, call OpenWD internally).
* Maintained in RAM by the OS.
* Valid until the application calls CloseWD (in FutureBasic: CLOSE FOLDER), or until the application quits.
* Each WDRN is associated with three data items: a Volume Reference Number and a Directory ID (which together identify the directory) and a 4-byte "Process ID" (which theoretically identifies the application that assigned the WDRN).
* You cannot delete the directory, nor unmount its volume, as long as any application still has the directory "open" (i.e. as long as a valid WDRN exists for the directory).

File ID Number
* Postive 32-bit integer.
* Within a given volume, uniquely identifies a file.
* In HFS volumes, every file has one. Other file systems may or may not support them.
* Rarely used, except "internally" by the Alias Manager.
* Maintained on disk as part of the file's information.
* Valid until the file is deleted
* Does not change if the file is renamed or moved (within the volume).

File System Specification (FSSpec) Record
* 70-byte record.
* Uniquely identifies an item (a file or directory) among all items on all currently mounted volumes.
* Consists of 3 fields:
> volume reference number of the volume containing the item (2 bytes);
> directory ID of item's parent directory (4 bytes);
> item's name (up to 64 bytes, in "Pascal string" (leading length-byte) format).
* Created and maintained by your application. You can either "build" one by concatenating the 3 necessary fields, or you can call FSMakeFSSpec. Also, some Toolbox routines create and return FSSpec records which your application then maintains.
* An FSSpec record that describes a non-existent item may still be "valid." (For example, you can pass such a record to a routine that creates the item).
* Valid until the item is renamed, or is moved to a different directory, or its volume is unmounted.
* Because shutdown always unmounts all volumes, you cannot count on an old FSSpec record to be still valid the next time you start up your system. For the same reason, you can't count on an FSSpec record which describes an item on an ejectable disk to be still valid if you unmount and then re-insert the disk.

Alias Record
* Unpublished internal format.
* Attempts to uniquely identify an item (a file or directory) even after "changes" have occurred; e.g.:
> volume reference number of item's volume has changed;
> item's volume is not currently mounted;
> item has been renamed, or moved to a different directory.
* Infinitely more effective and versatile than Microsoft's stupid "shortcuts."
* Created/updated at the request of an application, or by the Finder.
* Typically stored as an "alis" resource.

Path Name
* A string containing a file name and/or directory name(s) and/or colon(s).
* Attempts to uniquely identify an item (a file or directory) by (usually) listing the item's name along with a "chain" of (zero or more) "ancestor" directories that lead to the item.
* Two kinds:
> A "complete pathname" must begin with a volume name, followed by a colon.
> A "partial" (or "relative") pathname either begins with a colon, or contains no colons. It assumes some (unnamed) directory as a starting point for the specified path.
* Problems with path names:
> Limited to 255 characters;
ÿ A complete pathname can be ambiguous if there are two currently mounted volumes with identical names.

Rick