FSIsAliasFile deprecated - typeOfFile is slow
FSIsAliasFile deprecated - typeOfFile is slow
- Subject: FSIsAliasFile deprecated - typeOfFile is slow
- From: Leonardo <email@hidden>
- Date: Fri, 27 Nov 2015 23:00:16 +0100
- Thread-topic: FSIsAliasFile deprecated - typeOfFile is slow
Hi,
I actually detect whether a file is an alias this way:
I use a NSString category where self is the filePath.
- (BOOL)IsAliasOld
{
FSRef sourceRef;
OSErr err = [self GetFSRef:&sourceRef];
if(err) return NO;
Boolean isFSDirectory, aliasFileFlag;
err = FSIsAliasFile(&sourceRef, &aliasFileFlag, &isFSDirectory);
if(err) return NO;
else return aliasFileFlag;
}
- (OSErr)GetFSRef:(FSRef*)sourceRef
{
const char *cSrcPath = [[NSFileManager defaultManager]
fileSystemRepresentationWithPath:self];
if(cSrcPath == 0 || *cSrcPath == _NUL) return -1;
OSErr err = FSPathMakeRefWithOptions((UInt8*)cSrcPath,
kFSPathMakeRefDoNotFollowLeafSymlink, sourceRef, NULL);
return err;
}
Since FSIsAliasFile is deprecated (I compile for 10.9) I would now use
- (BOOL)IsAliasNew
{
NSString *type = [[NSWorkspace sharedWorkspace] typeOfFile:self
error:nil];
return [type isEqualToString:@"com.apple.alias-file"];
}
The problem is that the IsAliasNew method is 3.7 times slower than the
IsAliasOld method. Do you know a way to accomplish that with a faster
method?
Regards
-- Leonardo
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden