Re: Path to desktop
Re: Path to desktop
- Subject: Re: Path to desktop
- From: Micha Fuhrmann <email@hidden>
- Date: Tue, 10 Jul 2007 11:50:00 +0200
Thanks,
that's what I needed.
Micha
On 9 juil. 07, at 19:56, Chris Parker wrote:
On Jul 9, 2007, at 10:37 AM, Shawn Erickson wrote:
On 7/9/07, Micha Fuhrmann <email@hidden> wrote:
Do I really need to reconstruct the full path with
stringByAppendingPathComponent ?
There's got to be something simple!!!
Any help very much appreciated.
Try the following (note -[NSString stringByExpandingTildeInPath] and
-[NSString fileSystemRepresentation], the later should be used when
passing a path to a POSIX API, etc.)...
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSArray* paths;
paths = NSSearchPathForDirectoriesInDomains( NSDesktopDirectory,
NSUserDomainMask, NO );
NSString* fullPathToDesktop = [[paths objectAtIndex:0]
stringByExpandingTildeInPath];
const char* fullPathToDesktopFS = [fullPathToDesktop
fileSystemRepresentation];
NSLog(@"NSDesktopDirectory:\n %@ [%s]", fullPathToDesktop,
fullPathToDesktopFS);
[pool release];
return 0;
}
Color me (slightly) confused, but...
Why not just pass "YES" to the "expandTilde" parameter for
NSSearchPathForDirectoriesInDomains()?
I think you'll find this:
NSArray * paths = NSSearchPathForDirectoriesInDomains
(NSDesktopDirectory, NSUserDomainMask, YES);
NSString * desktop_path = [paths objectAtIndex:0];
gets you all the way there.
.chris
--
Chris Parker
Cocoa Frameworks
Apple, Inc.
_______________________________________________
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