type & creator vs. suffix

Not open for further replies.


hi there!

following question:

if you have a file with a type and creator, the macosx finder will be able to open the file by those informations (it will very likely start a classic app).

if you have a file with a suffix, the macosx finder will be able to open the file by those informations ( it will very likely start an osx app.)

now the hard part:

if you have a file without type and creator and without a suffix, the macosx finder will be able to open the file with the program used last.

for example:
if you remove the suffix (in the terminal with mv) from a file generated under osx (PDF or RTF), wich does not contain a type and creator. the finder will still start an app, even though the icon for the file is generic.

i have removed and updated the desktop files for os9 and osx, and still the same! i have removed the preferences of the program, wich contains the information about files to be opend by a certain suffix.

happens under osx 10.1.1



There is a flaw in your logic. Type and creator codes are still used by OS X native apps.

For example, take that pdf file of yours:
* Remove the .pdf extension
(using the Finder, or in the Terminal)
* Remove the type and creator codes
(using ResEdit, or by using /Developer/Tools/SetFile -c "" -t "" filename)
Now when you try to launch it, you will be told that an application cannot be found.

There is an order of preference (maybe someone can help me out with this). I believe:
type and creator - comes first
file suffix - comes next

Some simple file types, like flat text files with no type/creator or extension, are automatically opened by TextEdit. Does anyone know the formal rules in OS X governing file assignments?


start IE for OSX. print a page into a .pdf file. this file has no type or creator. remove the suffix via terminal. now try to open the file. ar opens the file. once you have opend it, look if it still has no type and creator. it has added PDF / CARO to the file.

as far as i know up to now, the finder first tries to look up type and creator, then looks for a suffix. if it has both it preferably uses the suffix.

but, if i try this following example i get confused again:

take simple text. save a file. view it in osx finder. it uses a osx icon (new since 10.1.!). look at type and creator -> TEXT; ttxt. add the suffix .jpg to it. view it in osx finder. it still uses the same icon. look at type and creator -> SUPRISE it has changed TYPE and CREATOR.

osx finder somehow knows not to be fooled anymore! the file is a textfile and not a jpg.

this is new!



I will propose an explanation...

the pdf file that I had originally tried this starts with:
stream14353 /O 14982 /E 14998 /Filter /FlateDecode /Length 16055 0 R >> ]

the pdf file that I get from printing to pdf:
2 0 obj
<< /Length 1 0 R /Filter /FlateDecode >>

When both files are stripped of their .pdf extension, and type & creator are set to "", the first gives "can't find application" error, while the second still launches with Acrobat. As I mentioned in the last post, TextEdit seems to still open plain text files with no distinguishable attributes.

I suspect that the OS scans the first few lines of an unknown file, and if it can match certain attributes (like ascii text, or %PDF) it will make a guess and open the file with that application.

I submit the following as proof:
create a plain text file (using vi or pico) containing the following lines:
2 0 obj
<< /Length 1 0 R /Filter /FlateDecode >>
this is a test

Clearly everything is ASCII plain text. Save it with a non-descriptive name like testfile. Now double-click on it in the Finder.

Now open the file, and change the "PDF" to "FDP". Save it. Now double-click on it in the Finder.



It's magic, literally (well, almost anyway). If you do a file filename (in Terminal) with the PDF text, it will return PDF document, version 1.3; if you use DPF text, it will return ASCII text. The file command (and probably the Finder when it doesn't have type/creator or an extension) uses /etc/magic to identify files based on some of the content. Have a look at /etc/magic to see how it works; if you search for "pdf:" in the file, you'll see the text it uses to identify PDF files.
Not open for further replies.