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 theResolveAliasFile
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 wantResolveAliasFile
to resolve all aliases in a chain, stopping only when it reaches the target file. Set this parameter toFALSE
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 returnsTRUE
in this parameter if the file specification record in the parametertheSpec
points to a directory or a volume; otherwise,ResolveAliasFile
returnsFALSE
in this parameter.wasAliased
- A return parameter only. The
ResolveAliasFile
function returnsTRUE
in this parameter if the file specification record in the parametertheSpec
points to an alias; otherwise,ResolveAliasFile
returnsFALSE
in this parameter.DESCRIPTION
TheResolveAliasFile
function returns in the parametertheSpec
the name and location of the target file that you initially pass in the parametertheSpec
.The
ResolveAliasFile
function first checks the catalog file for the file or directory specified in the parametertheSpec
to determine whether it is an alias and whether it is a file or a directory. If the object is not an alias,ResolveAliasFile
leavestheSpec
unchanged, sets thetargetIsFolder
parameter toTRUE
for a directory or volume andFALSE
for a file, setswasAliased
toFALSE
, and returnsnoErr
. If the object is an alias,ResolveAliasFile
resolves it, places the target in the parametertheSpec
, and sets thewasAliased
flag toTRUE
.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 offnfErr
and fills in the parametertheSpec
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 functionFSpCreate
.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 theResolveAliasFile
function, you should make sure that it is available by using theGestalt
function with thegestaltAliasMgrAttr
selector.RESULT CODES
noErr 0 No error nsvErr -35 Volume not found fnfErr -43 Target not found, but volume and parent directory found, and theSpec
parameter contains a valid
file system specification recorddirNFErr -120 Parent directory not found SEE ALSO
Listing 7-13 on page 7-39 illustrates how to useResolveAliasFile
from an application's ownMyOpen
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. TheGestalt
function is described in the chapter "Gestalt Manager" in Inside Macintosh: Operating System Utilities.