Determining general type of a file (image, text, sound, etc...)

2008-06-28 Thread kentozier
Hi

I'm writing a KFile class that encapsulates a bunch of file operations that 
are spread out over several Cocoa and Carbon classes and want to have a couple 
of testing methods such as isImageFile, isMusicFile, isTextFile etc. I'm 
trying to avoid hard coding HFS types and/or file extensions and have it 
perform these tests much like the Finder does in it's search window where you 
can specify file kind as Images, Music, Text, Movies etc. Is there any 
any built in way, in either Cocoa or Carbon, to get a list of types that 
correspond to say Images or perform a test on a specific file that returns 
true for Images?

Thanks for any help


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Determining general type of a file (image, text, sound, etc...)

2008-06-28 Thread Oleg Svirgstin

Hi Ken and all,

I would use the Uniform Type Identifiers (UTI), look at the ADC:
ADC Home  Reference Library  Guides  Carbon  Data Management   
Uniform Type Identifiers Overview .


I have used the UTI several times to identify image files and it  
worked well.


HTH,
Oleg




On Jun 29, 2008, at 01:37, [EMAIL PROTECTED] wrote:


Hi

I'm writing a KFile class that encapsulates a bunch of file  
operations that are spread out over several Cocoa and Carbon classes  
and want to have a couple of testing methods such as isImageFile,  
isMusicFile, isTextFile etc. I'm trying to avoid hard coding HFS  
types and/or file extensions and have it perform these tests much  
like the Finder does in it's search window where you can specify  
file kind as Images, Music, Text, Movies etc. Is there any  
any built in way, in either Cocoa or Carbon, to get a list of types  
that correspond to say Images or perform a test on a specific file  
that returns true for Images?


Thanks for any help



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Determining general type of a file (image, text, sound, etc...)

2008-06-28 Thread Owen Yamauchi
On Sat, Jun 28, 2008 at 2:37 PM,  [EMAIL PROTECTED] wrote:
 Hi

 I'm writing a KFile class that encapsulates a bunch of file operations that 
 are spread out over several Cocoa and Carbon classes and want to have a 
 couple of testing methods such as isImageFile, isMusicFile, isTextFile 
 etc. I'm trying to avoid hard coding HFS types and/or file extensions and 
 have it perform these tests much like the Finder does in it's search window 
 where you can specify file kind as Images, Music, Text, Movies etc. 
 Is there any any built in way, in either Cocoa or Carbon, to get a list of 
 types that correspond to say Images or perform a test on a specific file 
 that returns true for Images?

You could use the command-line utility file via an NSTask. Look at
its manpage for more info.

Owen
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]