• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Unicode filename and FSPathMakeRef
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unicode filename and FSPathMakeRef


  • Subject: Re: Unicode filename and FSPathMakeRef
  • From: Rainer Brockerhoff <email@hidden>
  • Date: Fri, 4 Jan 2002 08:38:41 -0200

>Date: Thu, 3 Jan 2002 17:02:00 -0600
>From: Chris Hanson <email@hidden>
>
>At 10:51 PM +0800 1/3/02, Johnny CN Lee wrote:
>>I get a path from FSRef using FSRefMakePath. How should I covert the path to
>>NSString?
>
>You shouldn't use FSRefMakePath -- there's no way to tell in advance
>how long the path will be, so you can't know how large a buffer to
>pass it. If you just randomly pick a size -- 1024 bytes, or 2048, or
>4096, or whatever -- it *will* be wrong for some user's system
>(particularly when using multibyte character sets) and you'll have
>needlessly built some fragile software.
>
>Instead, use CFURLCreateWithFSRef to get a CFURLRef corresponding to
>an FSRef, then call CFURLCopyFileSystemPath (with the constant
>kCFURLPOSIXPathStyle) to get a CFStringRef with a POSIX file system
>path. This CFStringRef can be used as if it were an NSString* thanks
>to toll-free bridging between CoreFoundation and the Foundation Kit.

Unfortunately, CFURLCreateWithFSRef calls FSRefMakePath internally, and uses a buffer of 1024 bytes with that. (All CF calls assume a maximum pathlength of 1024). At least in Darwin's CoreFoundation... Mac OS X's CF is supposed to be somewhat different, but probably not in that regard.

I've read some rants on the lists and elsewhere that this 1024 limit is way too low. (I use 16384 for my FSRefMakePath calls, but probably even that's too low for Japanese users.) Is there an official Apple position about how this will be addressed in the future? Which APIs are safe from this limit, anyway?

--
Rainer Brockerhoff <email@hidden>
Belo Horizonte, Brazil
"Originality is the art of concealing your sources."
http://www.brockerhoff.net/ (updated Dec. 2001)


  • Follow-Ups:
    • Re: Unicode filename and FSPathMakeRef
      • From: Chris Hanson <email@hidden>
  • Prev by Date: Are we all meanie-heads? No. (Was Re: The ULTIMATE...)
  • Next by Date: Re: services
  • Previous by thread: Re: Unicode filename and FSPathMakeRef
  • Next by thread: Re: Unicode filename and FSPathMakeRef
  • Index(es):
    • Date
    • Thread