Re: Symbolic links, alias files and related stuff
Re: Symbolic links, alias files and related stuff
- Subject: Re: Symbolic links, alias files and related stuff
- From: Andreas Schwarz <email@hidden>
- Date: Thu, 11 Apr 2002 12:22:46 -0700
Hmm, I just did a little test and LSCopyDisplayNameForRef() seems to
be twice as slow as [[NSFileManager defaultManager]
displayNameForPath:]. Maybe it's using something else?
How does LSCopyDisplayNameForURL() fare? Is it any faster?
Oh, hell no. I just did a lot of testing of all the LS functions I use
a lot, and it seems the FSRef ones are on average 4 times as fast as the
URL ones. Maybe I'm doing something wrong though. In any case, here's
the results of my (very informal) testing in this case (it seems the
results I got earlier weren't quite so accurate; NSFileManager is
faster, but not by too much):
Using FSRef: 1.569345 seconds
Using URL: 4.762220 seconds
Using NSFileManager: 1.441965 seconds
These are being called 9000 times each on my "Pictures" folder. The two
functions I'm using besides NSFileManger's method (if there's anything
stupid here, please tell me!):
static NSString * getDisplayName1(NSString *path) {
FSRef ref;
CFStringRef name;
if ((FSPathMakeRef([path fileSystemRepresentation], &ref, NULL) !=
noErr) || LSCopyDisplayNameForRef(&ref, &name) != noErr) {
return [path lastPathComponent];
}
return [(NSString *)name autorelease];
}
static NSString * getDisplayName2(NSString *path) {
CFStringRef name;
if (LSCopyDisplayNameForURL((CFURLRef)[NSURL fileURLWithPath:path],
&name) != noErr) {
return [path lastPathComponent];
}
return [(NSString *)name autorelease];
}
I think the Finder's a little schizo. :)
Seems like it ;-). Is there any way I can specify names for the new
files myself? Or perhaps get a hold of the newly created file
(AppleEvents can return stuff, I know, but I have no idea how or what to
do) and rename it afterwards?
Thanks again,
Andreas Schwarz
http://homepage.mac.com/schwarz
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.