LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Determining MIME Type of a File (https://www.linuxquestions.org/questions/linux-general-1/determining-mime-type-of-a-file-218099/)

Jose Muņiz 08-15-2004 10:24 PM

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 :D

Wynd 08-16-2004 01:04 AM

Try:

file name_of_file

SciYro 08-16-2004 01:44 AM

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) ....


All times are GMT -5. The time now is 03:25 AM.