Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Macintosh Toolbox Essentials /
Chapter 7 - Finder Interface / Finder Interface Reference
Routines / Resolving Alias Files


ResolveAliasFile

If your application bypasses the Finder when manipulating documents, it should check for and resolve aliases itself by using the ResolveAliasFile function.

FUNCTION ResolveAliasFile (VAR theSpec: FSSpec; 
                           resolveAliasChains: Boolean; 
                           VAR targetIsFolder: Boolean; 
                           VAR wasAliased: Boolean): OSErr;
theSpec
A file system specification record for the file or directory you plan to open.
resolveAliasChains
A Boolean value. Set this parameter to TRUE if you want ResolveAliasFile to resolve all aliases in a chain, stopping only when it reaches the target file. Set this parameter to FALSE if you want to resolve only one alias file, even if the target is another alias file.
targetIsFolder
A return parameter only. The ResolveAliasFile function returns TRUE in this parameter if the file specification record in the parameter theSpec points to a directory or a volume; otherwise, ResolveAliasFile returns FALSE in this parameter.
wasAliased
A return parameter only. The ResolveAliasFile function returns TRUE in this parameter if the file specification record in the parameter theSpec points to an alias; otherwise, ResolveAliasFile returns FALSE in this parameter.
DESCRIPTION
The ResolveAliasFile function returns in the parameter theSpec the name and location of the target file that you initially pass in the parameter theSpec.

The ResolveAliasFile function first checks the catalog file for the file or directory specified in the parameter theSpec to determine whether it is an alias and whether it is a file or a directory. If the object is not an alias, ResolveAliasFile leaves theSpec unchanged, sets the targetIsFolder parameter to TRUE for a directory or volume and FALSE for a file, sets wasAliased to FALSE, and returns noErr. If the object is an alias, ResolveAliasFile resolves it, places the target in the parameter theSpec, and sets the wasAliased flag to TRUE.

When ResolveAliasFile finds the specified volume and parent directory but fails to find the target file or directory in that location, ResolveAliasFile returns a result code of fnfErr and fills in the parameter theSpec with a complete file system specification record describing the target (that is, its volume reference number, parent directory ID, and filename or folder name). The file system specification record is valid, although the object it describes does not exist. This information is intended as a "hint" that lets you explore possible solutions to the resolution failure. You can, for example, use the file system specification record to create a replacement for a missing file with the File Manager function FSpCreate.

If ResolveAliasFile receives an error code while resolving an alias, it leaves the input parameters as they are and exits, returning an error code. In addition to any of these result codes, ResolveAliasFile can also return any Resource Manager or File Manager errors.

SPECIAL CONSIDERATIONS
Before calling the ResolveAliasFile function, you should make sure that it is available by using the Gestalt function with the gestaltAliasMgrAttr selector.

RESULT CODES
noErr0No error
nsvErr-35Volume not found
fnfErr-43Target not found, but volume and parent directory found, and theSpec parameter contains a valid
file system specification record
dirNFErr-120Parent directory not found
SEE ALSO
Listing 7-13 on page 7-39 illustrates how to use ResolveAliasFile from an application's own MyOpen function. The file system specification record is described in Inside Macintosh: Files. Aliases and other Alias Manager and File Manager routines
are also described in greater detail in Inside Macintosh: Files. The Gestalt function is described in the chapter "Gestalt Manager" in Inside Macintosh: Operating System Utilities.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 JUL 1996