Important: The information in this document is obsolete and should not be used for new development.
ResolveAliasFile
If your application bypasses the Finder when manipulating documents, it should check for and resolve aliases itself by using theResolveAliasFilefunction.
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
TRUEif you wantResolveAliasFileto resolve all aliases in a chain, stopping only when it reaches the target file. Set this parameter toFALSEif you want to resolve only one alias file, even if the target is another alias file.targetIsFolder- A return parameter only. The
ResolveAliasFilefunction returnsTRUEin this parameter if the file specification record in the parametertheSpecpoints to a directory or a volume; otherwise,ResolveAliasFilereturnsFALSEin this parameter.wasAliased- A return parameter only. The
ResolveAliasFilefunction returnsTRUEin this parameter if the file specification record in the parametertheSpecpoints to an alias; otherwise,ResolveAliasFilereturnsFALSEin this parameter.DESCRIPTION
TheResolveAliasFilefunction returns in the parametertheSpecthe name and location of the target file that you initially pass in the parametertheSpec.The
ResolveAliasFilefunction first checks the catalog file for the file or directory specified in the parametertheSpecto determine whether it is an alias and whether it is a file or a directory. If the object is not an alias,ResolveAliasFileleavestheSpecunchanged, sets thetargetIsFolderparameter toTRUEfor a directory or volume andFALSEfor a file, setswasAliasedtoFALSE, and returnsnoErr. If the object is an alias,ResolveAliasFileresolves it, places the target in the parametertheSpec, and sets thewasAliasedflag toTRUE.When
ResolveAliasFilefinds the specified volume and parent directory but fails to find the target file or directory in that location,ResolveAliasFilereturns a result code offnfErrand fills in the parametertheSpecwith 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 functionFSpCreate.If
ResolveAliasFilereceives 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,ResolveAliasFilecan also return any Resource Manager or File Manager errors.SPECIAL CONSIDERATIONS
Before calling theResolveAliasFilefunction, you should make sure that it is available by using theGestaltfunction with thegestaltAliasMgrAttrselector.RESULT CODES
noErr 0 No error nsvErr -35 Volume not found fnfErr -43 Target not found, but volume and parent directory found, and theSpecparameter contains a valid
file system specification recorddirNFErr -120 Parent directory not found SEE ALSO
Listing 7-13 on page 7-39 illustrates how to useResolveAliasFilefrom an application's ownMyOpenfunction. 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. TheGestaltfunction is described in the chapter "Gestalt Manager" in Inside Macintosh: Operating System Utilities.