Actually just FYI: Linux doesn't identify any type of file based on either method unless its set to executable, and you try to execute it, then it will check if its an elf executable that it can run, an a.out executable, or a text file that starts with something that looks like
Code: Select all
#!/path/to/program/that/interprets/code
echo "this is some code"
Only the higher level programs in Linux use either method. KDE (probably Gnome too) use a mix of extensions and filecontents (its called mime types, its whats used on the internet) to identify the files and I've noticed that Konqueror can generally load a folder with thousands of files faster than explorer can load a directory with a few dozen. Most programs in Linux put an extension on files anyways cause sometimes file contents can be similar (is it a txt file or an XML file??? whos to know???).
OS X seems to have a third way, I think it embeds in the resource fork the program that created the file. When opening if thats not there it falls back to other methods (not sure if it uses extensions at all).
The issue with trojans (tricking users = trojan) is only cause by Microsoft making it so some extensions are hidden, allowing the user to be tricked by HotGurlzzzzzzz.jpg.exe (though they probably would open it even if it said HotGurlzzzzzzz.exe which is the sad part...).
Possibly add API that allows you to directly have the OS return the mime type of a file (that may be better suited as a user level library though)?