Alias Manager Reference
| Framework | CoreServices/CoreServices.h |
| Declared in | Aliases.h |
Overview
The Alias Manager enables the creation and resolution of alias records, which are data structures that describe files, directories, and volumes in the file system. An alias record contains a "fingerprint" of a file system object. You can store the alias record instead of a file system reference, and use the Alias Manager to find the object again when it's needed. The Alias Manager contains algorithms for locating objects that have been moved, renamed, copied, or restored from backup.
The exact makeup of an alias record depends on the file system in which the object resides. The Alias Manager takes advantage of persistent object ids, creation dates, file types, creator codes and the like if they are available. By default, an object at the location stored in the alias record will be considered a stronger match than an object with the same file id in a different location. (You can alter this behavior by passing flags to the functions that resolve the alias.)
The Alias Manager supports two types of alias records. The standard alias contains as much information as the Alias Manager can gather from the underlying file system. The minimal alias only stores a subset of the information in a standard alias record. A minimal alias may be used when the object is unlikely to move, the reference is to be short-lived, or space is a critical issue (the exact space savings depends on the underlying file system format.) The standard alias is the preferred format because it is more robust.
The Finder supports the creation and use of alias files that contain alias records. Currently, OS X does not provide a way for other applications to create these alias files. The Alias Manager can identify and resolve Finder alias files, but it cannot create them.
Functions by Task
Creating and Updating Alias Records
-
FSNewAliasDeprecated in OS X v10.8 -
FSNewAliasFromPathDeprecated in OS X v10.8 -
FSNewAliasMinimalDeprecated in OS X v10.8 -
FSNewAliasMinimalUnicodeDeprecated in OS X v10.8 -
FSNewAliasUnicodeDeprecated in OS X v10.8 -
FSUpdateAliasDeprecated in OS X v10.8
Getting Alias Size
-
GetAliasSizeDeprecated in OS X v10.8 -
GetAliasSizeFromPtrDeprecated in OS X v10.8
Getting and Setting Alias User Types
-
GetAliasUserTypeDeprecated in OS X v10.8 -
GetAliasUserTypeFromPtrDeprecated in OS X v10.8 -
SetAliasUserTypeDeprecated in OS X v10.8 -
SetAliasUserTypeWithPtrDeprecated in OS X v10.8
Resolving and Reading Alias Records
-
FSMatchAliasDeprecated in OS X v10.5 -
FSMatchAliasNoUIDeprecated in OS X v10.5 -
FSCopyAliasInfoDeprecated in OS X v10.8 -
FSMatchAliasBulkDeprecated in OS X v10.8 -
FSResolveAliasDeprecated in OS X v10.8 -
FSResolveAliasWithMountFlagsDeprecated in OS X v10.8
Working With Finder Alias Files
-
FSFollowFinderAliasDeprecated in OS X v10.8 -
FSIsAliasFileDeprecated in OS X v10.8 -
FSResolveAliasFileDeprecated in OS X v10.8 -
FSResolveAliasFileWithMountFlagsDeprecated in OS X v10.8
Working With Universal Procedure Pointers to Alias Manager Callbacks
-
DisposeAliasFilterUPPDeprecated in OS X v10.8 -
InvokeAliasFilterUPPDeprecated in OS X v10.8 -
NewAliasFilterUPPDeprecated in OS X v10.8
Deprecated Functions
Alias Manager functions that use the FSSpec data type have been deprecated. Instead, you should use the equivalent FSRef–based functions, which include support for features such as unicode and long filenames. For more information on FSSpec and FSRef types, see File Manager Reference.
-
GetAliasInfoDeprecated in OS X v10.3 -
FollowFinderAliasDeprecated in OS X v10.5 -
MatchAliasNoUIDeprecated in OS X v10.5 -
ResolveAliasFileWithMountFlagsDeprecated in OS X v10.5 -
IsAliasFileDeprecated in OS X v10.4 -
MatchAliasDeprecated in OS X v10.4 -
NewAliasDeprecated in OS X v10.4 -
NewAliasMinimalDeprecated in OS X v10.4 -
NewAliasMinimalFromFullPathDeprecated in OS X v10.4 -
ResolveAliasDeprecated in OS X v10.4 -
ResolveAliasFileDeprecated in OS X v10.4 -
ResolveAliasFileWithMountFlagsNoUIDeprecated in OS X v10.4 -
ResolveAliasWithMountFlagsDeprecated in OS X v10.4 -
UpdateAliasDeprecated in OS X v10.4
Callbacks
AliasFilterProcPtr
Defines a pointer to an alias filtering callback function that filters out possible targets identified by the FSMatchAlias function.
typedef Boolean (*AliasFilterProcPtr) ( CInfoPBPtr cpbPtr, Boolean * quitFlag, Ptr myDataPtr );
If you name your function MyAliasFilterCallback, you would declare it like this:
Boolean MyAliasFilterCallback ( CInfoPBPtr cpbPtr, Boolean * quitFlag, Ptr myDataPtr );
Parameters
- cpbPtr
A pointer to a catalog information parameter block. When your function is called, the
cpbPtrparameter points to the catalog information parameter block of the possible match (returned by the File Manager functionPBGetCatInfo).- quitFlag
On exit, set this to
trueif you want to terminate the search.- myDataPtr
A pointer to any customized data that your application passed when it called
FSMatchAlias. This parameter allows your filter function to access any data that your application has set up on its own.
Return Value
Your function should return true to indicate that the possible match is to be discarded, or false to indicate that the possible match is to be added to the list of possible targets.
Discussion
You can write your own filter function to examine possible targets identified by the FSMatchAlias function. The FSMatchAlias function calls your filter function each time it identifies a possible match.
Availability
- Available in OS X v10.0 and later.
- Not available to 64-bit applications.
Declared In
Aliases.hFSAliasFilterProcPtr
Defines a pointer to an alias filtering callback function that filters out possible targets identified by the FSMatchAliasBulk function.
typedef Boolean (*FSAliasFilterProcPtr) ( FSRef *ref, Boolean *quitFlag, Ptr myDataPtr );
If you name your function MyFSAliasFilterCallback, you would declare it like this:
Boolean MyAliasFilterCallback ( FSRef *ref, Boolean *quitFlag, Ptr myDataPtr );
Parameters
- ref
A pointer to a file system object. When your function is called, the ref parameter points to the possible match.
- quitFlag
On output, set this Boolean flag to
trueif you want to terminate the search.- myDataPtr
A pointer to any customized data that your application passed when it called
FSMatchAliasBulk. This parameter allows your filter function to access any data that your application has set up on its own.
Return Value
Your function should return true to indicate that the possible match is to be discarded, or false to indicate that the possible match is to be added to the list of possible targets.
Discussion
You can write your own filter function to examine possible targets identified by the FSMatchAliasBulk function. The FSMatchAliasBulk function calls your filter function each time it identifies a possible match.
Availability
- Available in OS X v10.5 and later.
Declared In
Aliases.hData Types
AliasInfoType
Defines the alias record information type used in the index parameter of GetAliasInfo.
typedef short AliasInfoType;
Availability
- Available in OS X v10.0 and later.
Declared In
Aliases.hAliasFilterUPP
Defines a universal procedure pointer (UPP) to an alias filtering function.
typedef AliasFilterProcPtr AliasFilterUPP;
Discussion
See FSAliasFilterProcPtr for more information on alias filtering functions.
Availability
- Available in OS X v10.0 and later.
- Not available to 64-bit applications.
Declared In
Aliases.hAliasRecord
Defines an alias record.
struct AliasRecord {
OSType userType;
unsigned short aliasSize;
};
typedef struct AliasRecord AliasRecord;
typedef AliasRecord * AliasPtr;
typedef AliasPtr * AliasHandle;
Fields
userTypeA 4-byte field that can contain application-specific data. When an alias record is created, this field contains 0. Your application can use this field for its own purposes.
aliasSizeThe size, in bytes, assigned to the alias record at the time of its creation or updating. This is the total size of the record, including the
userTypeandaliasSizefields, as well as the variable-length data that is private to the Alias Manager.
Discussion
The Alias Manager uses alias records to store information that allows it to locate an object in the file system.
Availability
- Available in OS X v10.0 and later.
Declared In
Aliases.hFSAliasInfo
Defines an information block passed to the FSCopyAliasInfo function.
struct FSAliasInfo {
UTCDateTime volumeCreateDate;
UTCDateTime targetCreateDate;
OSType fileType;
OSType fileCreator;
UInt32 parentDirID;
UInt32 nodeID;
UInt16 filesystemID;
UInt16 signature;
Boolean volumeIsBootVolume;
Boolean volumeIsAutomounted;
Boolean volumeIsEjectable;
Boolean volumeHasPersistentFileIDs;
Boolean isDirectory;
};
typedef struct FSAliasInfo FSAliasInfo;
typedef FSAliasInfo * FSAliasInfoPtr;
Fields
volumeCreateDateThe creation date of the volume on which the alias target resides.
targetCreateDateThe creation date of the alias target.
fileTypeThe file type of the target.
fileCreatorThe creator code of the target.
parentDirIDThe directory ID of the target’s parent directory.
nodeIDThe ID of the file or directory that is the alias target.
filesystemIDThe filesystem ID.
signatureThe volume signature of the volume on which the target resides.
volumeIsBootVolumeA Boolean value indicating whether the volume is the boot volume.
volumeIsAutomountedA Boolean value indicating whether the volume is automounted.
volumeIsEjectableA Boolean value indicating whether the volume is ejectable.
volumeHasPersistentFileIDsA Boolean value indicating whether the volume has persistent file ID’s.
isDirectoryA Boolean value indicating whether the alias target is a directory.
Availability
- Available in OS X v10.2 and later.
Declared In
Aliases.hConstants
Alias Information Masks
Returned by the FSCopyAliasInfo function to indicate which fields of the alias information structure contain valid data.
typedef UInt32 FSAliasInfoBitmap;
enum {
kFSAliasInfoNone = 0x00000000,
kFSAliasInfoVolumeCreateDate = 0x00000001,
kFSAliasInfoTargetCreateDate = 0x00000002,
kFSAliasInfoFinderInfo = 0x00000004,
kFSAliasInfoIsDirectory = 0x00000008,
kFSAliasInfoIDs = 0x00000010,
kFSAliasInfoFSInfo = 0x00000020,
kFSAliasInfoVolumeFlags = 0x00000040
};
Constants
kFSAliasInfoNoneNone of the alias information is valid.
Available in OS X v10.2 and later.
Declared in
Aliases.h.kFSAliasInfoVolumeCreateDateThe volume creation date in the
volumeCreateDatefield is valid.Available in OS X v10.2 and later.
Declared in
Aliases.h.kFSAliasInfoTargetCreateDateThe creation date of the alias target, in the
targetCreateDatefield, is valid.Available in OS X v10.2 and later.
Declared in
Aliases.h.kFSAliasInfoFinderInfoThe file type and creator information, in the
fileTypeandfileCreatorfields, is valid.Available in OS X v10.2 and later.
Declared in
Aliases.h.kFSAliasInfoIsDirectoryThe information in the
isDirectoryfield is valid.Available in OS X v10.2 and later.
Declared in
Aliases.h.kFSAliasInfoIDsThe parent directory ID and alias target ID, in the
parentDirIDandnodeIDfields, are valid.Available in OS X v10.2 and later.
Declared in
Aliases.h.kFSAliasInfoFSInfoThe filesystem ID and signature, in the
filesystemIDandsignaturefields, are valid.Available in OS X v10.2 and later.
Declared in
Aliases.h.kFSAliasInfoVolumeFlagsThe volume information, in the
volumeIsBootVolume,volumeIsAutomounted,volumeIsEjectable, andvolumeHasPersistentFileIDsfields, is valid.Available in OS X v10.2 and later.
Declared in
Aliases.h.
Volume Mount Options
Specify how an alias should be resolved.
enum {
kResolveAliasFileNoUI = 0x00000001,
kResolveAliasTryFileIDFirst = 0x00000002
};
Constants
kResolveAliasFileNoUIThe Alias Manager should resolve the alias without presenting a user interface.
Available in OS X v10.0 and later.
Declared in
Aliases.h.kResolveAliasTryFileIDFirstThe Alias Manager should search for the alias target using file IDs before searching using the path.
Available in OS X v10.2 and later.
Declared in
Aliases.h.
Discussion
The FSResolveAliasWithMountFlags, FSResolveAliasFileWithMountFlags, ResolveAliasWithMountFlags, ResolveAliasFileWithMountFlags, and ResolveAliasFileWithMountFlagsNoUI functions take these constants in the mountFlags parameter, allowing you to specify how the alias should be resolved.
Matching Constants
Specify the matching criteria for the alias matching functions.
enum {
kARMMountVol = 0x00000001,
kARMNoUI = 0x00000002,
kARMMultVols = 0x00000008,
kARMSearch = 0x00000100,
kARMSearchMore = 0x00000200,
kARMSearchRelFirst = 0x00000400,
kARMTryFileIDFirst = 0x00000800
};
Constants
kARMMountVolAutomatically try to mount the target’s volume if it is not mounted.
Available in OS X v10.0 and later.
Declared in
Aliases.h.kARMNoUIStop if a search requires user interaction, such as a password dialog box when mounting a remote volume. If user interaction is needed and
kARMNoUIis in effect, the search fails.Available in OS X v10.0 and later.
Declared in
Aliases.h.kARMMultVolsSearch all mounted volumes. The search begins with the volume on which the target resided when the record was created. When you specify a fast search of all mounted volumes,
MatchAliasperforms a formal fast search only on the volume described in the alias record. On all other volumes it looks for the target by ID or by name in the directory with the specified parent directory ID. When you specify an exhaustive search of multiple volumes,MatchAliasperforms the same search on all volumes. When resolving an alias record created byNewAliasMinimalFromFullPath,MatchAliasignores this flag.Available in OS X v10.0 and later.
Declared in
Aliases.h.kARMSearchPerform a fast search for the alias target. If
kARMSearchRelFirstis not set, perform an absolute search first, followed by a relative search only if the value of thefromFileparameter is notNULLand the list of matches is not full.Available in OS X v10.0 and later.
Declared in
Aliases.h.kARMSearchMorePerform an exhaustive search for the alias target. On HFS volumes, the exhaustive search uses the File Manager function
PBCatSearchto identify candidates with matching creation date, type, and creator. ThePBCatSearchfunction is available only on HFS volumes and only on systems running version 7.0 or later. On MFS volumes or HFS volumes that do not supportPBCatSearch, the exhaustive search makes a series of indexed calls to File Manager functions, using the same search criteria. If you setkARMSearchMoreand either or both ofkARMSearchandkARMSearchRelFirst,MatchAliasperforms the fast search first.Available in OS X v10.0 and later.
Declared in
Aliases.h.kARMSearchRelFirstIf
kARMSearchis also set, perform a relative search before the absolute search. (IfkARMSearchis also set and the target is found through the absolute search,MatchAliassets theneedsUpdateflag totrue.) If neitherkARMSearchnorkARMSearchMoreis set, perform only a relative search. IfkARMSearchis not set butkARMSearchMoreis set, perform a relative search followed by an exhaustive search.Available in OS X v10.0 and later.
Declared in
Aliases.h.kARMTryFileIDFirstPerform a search using the file ID of the target before searching using the path.
Available in OS X v10.2 and later.
Declared in
Aliases.h.
Discussion
The FSMatchAlias, FSMatchAliasNoUI, MatchAliasNoUI and MatchAlias functions use these constants to specify the matching criteria by passing a sum of these constants in the rulesMask parameter. You must specify at least one of the last three parameters: kARMSearch, kARMSearchMore, and kARMSearchRelFirst.
Alias Resource Type
Specifies the file type of an alias resource file.
enum {
rAliasType = 'alis'
};
Information Type Constants
The GetAliasInfo function uses these constants in the index parameter.
enum {
asiZoneName = -3,
asiServerName = -2,
asiVolumeName = -1,
asiAliasName = 0,
asiParentName = 1
};
Constants
asiZoneNameIf the record represents a target on an AppleShare volume, retrieve the server’s zone name. Otherwise, return an empty string.
Available in OS X v10.0 and later.
Declared in
Aliases.h.asiServerNameIf the record represents a target on an AppleShare volume, retrieve the server name. Otherwise, return an empty string.
Available in OS X v10.0 and later.
Declared in
Aliases.h.asiVolumeNameReturn the name of the volume on which the target resides.
Available in OS X v10.0 and later.
Declared in
Aliases.h.asiAliasNameReturn the name of the target.
Available in OS X v10.0 and later.
Declared in
Aliases.h.asiParentNameReturn the name of the parent directory of the target of the record. If the target is a volume, return the volume name.
Available in OS X v10.0 and later.
Declared in
Aliases.h.
Gestalt Constants
You can check for version and feature availability information by using the Alias Manager selectors defined in the Gestalt Manager. For more information, see Gestalt Manager Reference.
© 2003, 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-07-23)