How Documents Know Their Parents
Every operating system needs a mechanism to associate documents with the applications that created them. When you double-click a Microsoft Word document icon, for example, it's clear that you want Microsoft Word to launch and open the document.
So how does Mac OS X know how to find a document's mommy?
It actually has four different mechanisms.
Your preferences. If you've used the "Always Open with" command to specify a program (Reassigning a certain document—just once), that's the one that opens.
Type/Creator codes. First, it checks to see if the document has an invisible, four-letter Type code and Creator code. It does that because that's how Mac OS 9 used to recognize documents, and Mac OS X wants to ensure compatibility. (Apple used to monitor and track these four-letter codes, in conjunction with the various Mac software companies, so that no two creator codes were alike.)
The Creator code is the same for a program and the documents it creates—MSWD for Microsoft Word, FMP7 for FileMaker Pro, and so on. That's the entire point: The creator code tells the Mac which program to open when you double-click a particular document.
The Type code, meanwhile, specifies the document's file format: GIF, JPEG, TIFF, and so on.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access