• 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: Finder Info
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Finder Info


  • Subject: Re: Finder Info
  • From: Charles Srstka <email@hidden>
  • Date: Sat, 25 Aug 2012 09:50:23 -0500

On Aug 25, 2012, at 4:26 AM, Mike Abdullah <email@hidden> wrote:

> On 25 Aug 2012, at 06:03 AM, Jens Alfke <email@hidden> wrote:
>
>>
>> On Aug 24, 2012, at 8:59 PM, koko <email@hidden> wrote:
>>
>>> Excellent … much easier than
>>
>> Well, in Carbon's defense, you're making things a lot harder than they have to be:
>>
>>>      if(m_FSRef) free((void*)m_FSRef);
>>>      m_FSRef = malloc(sizeof(FSRef));
>>
>> FSRefs don't have to be allocated on the heap. They're just structs. (Ditto with the FSCatalogInfo you use later.)
>>
>>>      memset(m_FSRef,0x00,sizeof(FSRef));
>>
>> There's no need to zero one out before initializing it.
>>
>>>      const UInt8 *cpath = (const UInt8 *)[path cStringUsingEncoding:NSUTF8StringEncoding];
>>
>> -UTF8String is shorter.
>>
>> So you can reduce all the quoted stuff to one line:
>>
>>   OSStatus osStatus = FSPathMakeRef((const UInt8 *)[path UTF8String], &m_FSRef, false);
>>
>> assuming you declare m_FSRef as an FSRef, not FSRef*.
>
> I think you should use-fileSystemRepresentation instead of -UTF8String too, but not 100% sure

-fileSystemRepresentation is indeed the correct thing to use here. However, I'd recommend using CFURLGetFSRef() instead of FSPathMakeRef(), so that you can keep your code URL-based instead of path-based as much as possible.

Charles
_______________________________________________

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


References: 
 >Re: Finder Info (From: Greg Guerin <email@hidden>)
 >Re: Finder Info (From: koko <email@hidden>)
 >Re: Finder Info (From: Jens Alfke <email@hidden>)
 >Re: Finder Info (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Re: Sandboxing die.die.die
  • Next by Date: Re: NSView -backingAlignedRect:
  • Previous by thread: Re: Finder Info
  • Next by thread: Re: Finder Info
  • Index(es):
    • Date
    • Thread