• 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: Text file types
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Text file types


  • Subject: Re: Text file types
  • From: Sherm Pendley <email@hidden>
  • Date: Wed, 5 Feb 2003 10:18:30 -0500

On Wednesday, February 5, 2003, at 07:12 AM, Angela Brett wrote:

My other question is, is there a method (perhaps something like NSImage's - imageFileTypes) which I can use to determine whether a file is likely to be some sort of text file? I don't mean just checking for files with the .txt or .text extensions, I want to include other text files such as html and C.

If you want to avoid checking for extensions and/or HFS file type, you could use magic. First you need some candles and a chicken... Just kidding. :-)

Seriously though - the UNIX 'file' command looks for, among other things, magic numbers that appear at specific points in various file types. You could leverage this in one of two ways:

Either run the 'file' command on each file you're interested in, and examine the command's output.

Or, you can directly use the magic-number database yourself, and duplicate the file command's functionality in your app. The database is in /etc/magic, and its format - which is quite simple - is described in the 'magic' man page.

sherm--

If you listen to a UNIX shell, can you hear the C?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Text file types (From: Angela Brett <email@hidden>)

  • Prev by Date: Undefined symbols at launch time: _NSApplicationLoad
  • Next by Date: Welcome To Macintosh Startup Screen (first-launch)
  • Previous by thread: Text file types
  • Next by thread: Re: Text file types
  • Index(es):
    • Date
    • Thread