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: Can't convert path ~/... to Fsref



That's WAY too much work. ;-)

CFStringRef unlovedPath=CFSTR("~/Library/Preferences/");
CFStringRef lovedPath=(CFStringRef)objc_msgSend((id)unlovedPath, NSSelectorFromString((NSString*)CFSTR("stringByExpandingTildeInPath")));


But all of this assumes you're on Tiger. Otherwise you'll have to link to Foundation.framework manually. but the above doesn't require you change your source code file's extension/type at all. You can even redclare NSSelectorFromString to take a CFStringRef instead of an NSString* so you wouldn't even have to include the Foundation header in your source file, just the objc.h and objc-runtime. headers or whatever (that's what I did).

Ack, at 9/29/05, Bryan Prusha said:

Yes, true. If a '~' exists the home directory could be concatenated manually by calling FSFindFolder with kUserDomain and kCurrentUserFolderType then converting that FSRef to a path. Of course that's probably the kind of work you're trying to avoid. FWIW, if you're running on Tiger an linking against Carbon then you already have Foundation loaded automatically. If you can compile your code with Objective-C++ you can go ahead and use the Cocoa NSString convenience methods that have been mentioned. Cabrbon and Foundation wore very well together.


On Sep 29, 2005, at 1:36 PM, Rosyna wrote:

I don't believe that CFURLCreateWithFileSystemPath does shell expansion (the documentation makes no note of it doing this). glob does shell exapansion. You can just feed all path strings to it along with the GLOB_NOESCAPE and GLOB_TILDE flags. It will then expand any paths starting with ~ to the correct path. This is similar to NSString's -stringByExpandingTildeInPath method.

Ack, at 9/29/05, Bryan Prusha said:

How about CFURLCreateWithFileSystemPath followed by CFURLGetFSRef?

--


Sincerely, Rosyna Keller Technical Support/Holy Knight/Always needs a hug

Unsanity: Unsane Tools for Insanely Great People

It's either this, or imagining Phil Schiller in a thong.
_______________________________________________
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: 
 >Can't convert path ~/... to Fsref (From: "Denis @ TheOffice" <email@hidden>)
 >Re: Can't convert path ~/... to Fsref (From: Rosyna <email@hidden>)
 >Re: Can't convert path ~/... to Fsref (From: "Denis @ TheOffice" <email@hidden>)
 >Re: Can't convert path ~/... to Fsref (From: Bryan Prusha <email@hidden>)
 >Re: Can't convert path ~/... to Fsref (From: Rosyna <email@hidden>)
 >Re: Can't convert path ~/... to Fsref (From: Bryan Prusha <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.