• 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: Enumerating a folder and getting a file's type
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Enumerating a folder and getting a file's type


  • Subject: Re: Enumerating a folder and getting a file's type
  • From: Ken Thomases <email@hidden>
  • Date: Thu, 16 Oct 2008 18:31:22 -0500

On Oct 16, 2008, at 5:46 PM, email@hidden wrote:

I'm enumerating a folder and checking the extension but I would also like to check the type in case there is no extension. Like "AIFF Audio File" for .aif file. How do you do that?

The narrow answer to your question is: make an NSURL from the file path and pass it to LSCopyKindStringForURL (NSURL is toll-free bridged with CFURLRef).


However, you should consider working with UTIs (Uniform Type Identifiers) rather than checking either extensions or kind strings. Read up on UTIs here: <http://developer.apple.com/documentation/Carbon/Conceptual/understanding_utis/ >.

You can use the NSWorkspace methods to check whether a file's UTI conforms to the type(s) you want to handle: -typeOfFile:error: and - type:conformsToType:. For AIFF audio, you want to check for conformance to the UTI "public.aiff-audio".

Cheers,
Ken

_______________________________________________

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: 
 >Enumerating a folder and getting a file's type (From: email@hidden)

  • Prev by Date: Re: executables for OSX 10.4 vs 10.5
  • Next by Date: Re: executables for OSX 10.4 vs 10.5
  • Previous by thread: Enumerating a folder and getting a file's type
  • Next by thread: Object is not reachable from this managed object context
  • Index(es):
    • Date
    • Thread