Mailing Lists: Apple Mailing Lists

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

Re: Getting the current user dir in Carbon



A couple of other ways to grab the current home directly. Strictly POSIX style and it depends on the HOME environment variable being set (Which seems to be the case for OS X).

USE getenv.

	const char *h1 = getenv("HOME");
	fprintf(stderr, "HOME: %s\n", h1);

USE the built in environment pointer passed in main (Yes this is in the standards)...

int main (int argc, const char * argv[], const char *envp[]) {
	int i;
	for (i = 0; NULL != envp[i]; ++i)
		fprintf(stderr, "VAR: %s\n", envp[i]);
	return 0;
}

Cheers

On Nov 16, 2004, at 4:41 AM, Neil A. Van Note wrote:

This is something similar to what I have been using. Sans error checking and whatnot...

FSRef fsRef;
OSStatus err = FSFindFolder(kUserDomain, kCurrentUserFolderType, FALSE, &fsRef);
CFURLRef home = CFURLCreateFromFSRef(kCFAllocatorDefault, &fsRef);
CFURLRef path = CFURLCreateCopyAppendingPathComponent(kCFAllocatorDefault, home, CFSTR("work"), TRUE);
CFURLGetFSRef(path, &fsRef);
// PARTY on fsRef...
CFRelease(home);
CFRelease(path);


On Nov 16, 2004, at 1:02 AM, OL&L Lists wrote:

This may be a newbie question, but how do I specify the current user directory using a POSIX-style pathname in Carbon? I need to delete a directory directly inside the current user directory so I need to make a fixed path as a POSIX pathname string and then convert it to an FSRef.

Thanks,

Michael
Orbital Launch & List, Inc.
http://www.orbitallaunch.com
_______________________________________________
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


_______________________________________________ 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


_______________________________________________ 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
References: 
 >Getting the current user dir in Carbon (From: OL&L Lists <email@hidden>)
 >Re: Getting the current user dir in Carbon (From: "Neil A. Van Note" <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.