Re: NSApplicationSupportFolder
Re: NSApplicationSupportFolder
- Subject: Re: NSApplicationSupportFolder
- From: Stephan Burlot <email@hidden>
- Date: Tue, 28 Dec 2004 11:11:11 +0100
Nice idea! I had this code floating around that I copied from
<http://nslog.com/archives/2004/11/12/the_hacks_we_write.php>
Here's the code:
NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate];
NSAppleScript *as = [[NSAppleScript alloc] initWithSource:@"POSIX path
of (path to application support)"];
NSAppleEventDescriptor *aed = [as executeAndReturnError:NULL];
[as release];
NSString *appSupportPath = [NSString stringWithString:([aed
stringValue] ? [aed stringValue] : @"/Library/Application Support (hard
wired)")];
NSLog(@"App support: %@", appSupportPath);
2004-12-28 11:01:35.818 Fruchte[10654] App support:
/Library/Application Support/
2004-12-28 11:01:35.818 Fruchte[10654] Total Run Time = 0.452956
Runs in 0.45 seconds on a G4 1GHz.
Of course, the (hard wired) is just there to show me if the applescript
has failed.
Script can be changed to "POSIX path of (path to application support
from user domain)" to get the user's application support.
Of course, FSFindFolder would be 1000 times faster, I suppose.
Stephan
Le 28 déc. 04, à 01:49, BK a écrit :
On Dec 28, 2004, at 4:03, Sean McBride wrote:
Hard coding paths is very bad. "Application Support" may change
names in
the future. Using the FSFindFolder API is best and safest.
AppleScript's Standard Additions have a command to return the path to
the Application Support folder.
POSIX path of (path to application support)
--> "/Library/Application Support/"
Even if Apple was to change the path in the future, this should still
return the correct path.
So, what you could do is have your application run an embedded one
line AppleScript to obtain the path and then store it away for use
throughout your code.
Not for purists, but safe and performance shouldn't be an issue if you
call this only once.
rgds
bk _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden