Re: Enumerating a folder and getting a file's type
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