LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-15-2004, 10:24 PM   #1
Jose Muņiz
Member
 
Registered: Jul 2003
Location: Mexico City
Distribution: Slackware 9.1, SuSE 9.1
Posts: 248

Rep: Reputation: 32
Determining MIME Type of a File


I have a quick question... where is the MIME Type of a file stored? According to what I've read, it's not in the inode. (Why not?).

Now, I don't think it is determined based on the extension of the file, because I have files named without extensions and they have their MIME Type correctly defined.

Thank you for your help
 
Old 08-16-2004, 01:04 AM   #2
Wynd
Member
 
Registered: Jul 2001
Distribution: Slackware 12
Posts: 511

Rep: Reputation: 32
Try:

file name_of_file
 
Old 08-16-2004, 01:44 AM   #3
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
most programs use the extension to get the file type (stupid programs. ... should be shot)

anyways .. its faster to get the file type by the extension .. but in case of certain programs, its best to use the hearer of the file to determine what to do with it (like a file manager, should display files based on there extension for speed, and execute the program based on header value, as to not evidently run a mpg as a web page,.............)

anyways, in the first part of most file types (except plain text) they usually have a special number, or word thats common to all files of that type (look at the file manager worker .. it determines file types this way .. you can set up a file type by telling it to look at 3 files, it compares the heads of all these files and takes what is common in all and uses that to determine of a file is of that type)

anyways, with shared mime info from freedesktop.org , it stores both extension, and i believe what is called magic numbers (the header common to all files of this type you could say) ....
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't find Mime Type cootetom SUSE / openSUSE 20 08-16-2005 01:58 PM
CGI in C: need help determining mime types of files Sm0k3 Programming 1 01-26-2004 10:55 PM
how do I change mime type? brian_eye Linux - Newbie 2 06-10-2002 09:14 AM
Mime type settings saravanan1979 Linux - Newbie 0 04-15-2002 05:53 AM
Missing MIME type odat Programming 1 08-16-2001 05:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration