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





And now that we have the user directory, how to create a private folder into it and then create some file this folder .
We got the FsRef of the user domain, but how to get a FsRef ( then a FsSpec) to a non existing folder/file path ?


OSStatus err = FSFindFolder(kUserDomain, kCurrentUserFolderType, FALSE, &fsRef);
CFURLRef home = CFURLCreateFromFSRef(kCFAllocatorDefault, &fsRef);
CFURLRef path = CFURLCreateCopyAppendingPathComponent(kCFAllocatorDefault, home, CFSTR("SomeFolder"), TRUE);
bOK= CFURLGetFSRef(path, &fsRef); // Does not work .... the folder must already exist !... shit
result = FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL, NULL, &outSpec, NULL);
CFRelease(home);
CFRelease(path);

FSMakeFSRefUnicode does not work either.

Thanks


That's what I get for spending 13 years in Mac OS 9-only development. :-)

Thanks,

Michael

At 7:32 AM -0800 11/16/04, Eric Schlegel wrote:
On Nov 15, 2004, at 10:20 PM, OL&L Lists wrote:

I've tried:

UInt8 *userslibPathPOSIX = "./lib";

This depends on the current working directory being set correctly.
You can't depend on that unless you set it yourself.

and

UInt8 *userslibPathPOSIX = "~/lib";

The ~ character is expanded by the shell, not by the operating
system. That is, if you're in tcsh, and you type ~, then tcsh
expands that character out to the user's home directory; but passing
that character to a posix API will just interpret it literally and
won't expand it.

UInt8 *userslibPathPOSIX = "Users/~/lib";

same as above.

UInt8 *userslibPathPOSIX = "$HOME/lib";

Again, the $HOME syntax is shell syntax, and is only expanded by a
command shell. It's not expanded by posix APIs.

-eric


 _______________________________________________
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



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.