Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Beware resolving aliases with custom userTypes on Intel Macs.



From rdar://4576703:

There is a bug on Intel Macs whereby calling FSResolveAlias with a fromFile to do a relative resolve will cause the aliases' userType field to be swapped.

For example, given the following code:

FSRef XcodeRef;
if (FSPathMakeRef((const UInt8*)("/Developer/Applications/ Xcode.app"), &XcodeRef, nil) == noErr)
{
FSRef prefsRef;
if (FSFindFolder(kUserDomain,kPreferencesFolderType,true,&prefsRef) == noErr)
{
AliasHandle alias = nil;
if (FSNewAlias(&prefsRef,&XcodeRef,&alias) == noErr)
{
const OSType myType = 'parC';
SetAliasUserType(alias, myType);
OSType typeAfterSetting = GetAliasUserType(alias);
if (typeAfterSetting != myType)
printf("userType has been mashed setting it!.\n");
else
printf("userType has survived being set.\n");

FSRef resolvedRef;
Boolean wasChanged;
if (FSResolveAlias(nil,alias,&resolvedRef,&wasChanged) == noErr)
{
OSType typeAfterNonRelativeResolve = GetAliasUserType(alias);
if (typeAfterNonRelativeResolve != typeAfterSetting)
printf("userType has been mashed by the non-relative resolver. \n");
else
printf("userType has survived the non-relative resolver.\n");

if (FSResolveAlias(&prefsRef,alias,&resolvedRef,&wasChanged) == noErr)
{
OSType typeAfterRelativeResolve = GetAliasUserType(alias);
if (typeAfterRelativeResolve != typeAfterNonRelativeResolve)
printf("userType has been mashed by the relative resolver.\n");
else
printf("userType has survived the relative resolver.\n");
}
}
DisposeHandle((Handle)alias);
}
}
}


The output on an Intel mac will be:

userType has survived being set.
userType has survived the non-relative resolver
userType has been mashed by the relative resolver

Matt Gough
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.