Why did the Mac OS do a U-turn and adopt
filename extensions?
To any computer, even devices that contain
computers but present themselves to consumers as smartphones or tablets, files
are just discrete storage units, and folders just containers for files.
However, when you tap or double-click on the icon representing a file or
folder, you expect the computer to know what you want to do. In the case of an
application, it should start up; a document should be opened by the default app
set to handle that type of document; a folder should open and reveal its
contents.
In the bad old days, the Mac used to be the only computer that didn’t use
filename extensions
On a classic Mac running OS 9, your
double-click is passed to the Finder, which then looks in its hidden database
to see what type of object you’ve tried to open. Every file there has two
four-character codes giving the file type and its creator. In the case of
applications, they have the type APPL, so the Finder knows to start them; in
the case of a document, the Finder tries to start the application indicated as
being the document’s creator.
These Finder metadata are moved around in a
special storage area associated with every file in the Macintosh Extended (HFS+)
volume format, its resource fork. Lesser file systems (and operating systems)
view files as consisting of just a single glob of data; HFS+, ‘classic’ Mac OS
and OSX all allow each file to have two (or more) forks. The first, the same as
that basic glob of data on other file systems, is the data fork; the second,
almost unique to the Mac, is the resource fork, and consists of structured
information including the Finder metadata that sets the file type and creator.
So on Classic Mac systems, you can name applications, documents and most other
files almost anything you like, as the name isn’t linked to the type of thing
that file is.
When Apple was developing the first release
of OSX, many of its engineers didn’t come from a Mac background, but were Unix wizards,
brought up in the tradition that filename extensions indicate what a file is:
.text or .txt indicates a generic text document, .config or .cfg a special
text-format Unix configuration file, and so on. The hybrid operating system
that became OSX had to please two different philosophical stances, two opposed
schools of thought. The perfect compromise was to support both approaches, Mac
and UNIX. However, over the years those dyed-in-the-wool Mac engineers have
become fewer in number, so OSX has steadily become more insistent on the use of
correct filename extensions.
Folder and wiser, applications are actually folders with a set structure,
which the Finder pretends are single objects assigned the app’s custom icon
Apple has kept the magic in the Finder,
maintaining its illusion even though the interface has changed so much. Whereas
classic Mac applications stored a lot of ancillary information in the resource
fork, such as localized versions of its menus and dialog contents, icons and
other paraphernalia, OSX applications have to do this within a folder that
looks like an application. This trick, of disguising folders as single
file-like objects, extends to several other special items, such as installer
packages and other bundles.
As such, OSX has inexorably moved away from
using the resource fork, despite HFS+ still supporting them. This has
significant benefits, as resource forks are notoriously non-standard. Copy a
file with a resource fork onto a disk formatted using an MS-DOS FAT format,
such as a memory stick, and the contents of the resource fork.
OSX does still keep hidden files that
indicate which applications can open which types of document, and which should
as a default. You can see these at work when you select a document and
Ctrl-click (or secondary-click) to bring up the Finder’s contextual menu. At
the top it will offer to open the document using its default application, below
that listing other applications that are designated as being capable of
opening this document type, including a link to the App Store to look for
further possibilities.
Show or hide filename extensions using the Finder’s Preferences dialog,
under the advanced tool, or in general utilities
Alternatively select the document and use
the Finder’s Get Info command to show a dialog including the Open with section
listing the application set to open that document by default. This is the
normal way in which you can change that default, either for that document alone
or for all of its type, by changing the application set and then clicking on
the Change All... button.
RCDefaultApp is a free System Preferences
pane from rubicode.com/ Software/RCDefaultApp that gives you more direct
control over these settings: its Apps tab lists all the applications that it
can find on your Mac, and for each shows the file extensions that app can
open; the Extensions tab lets you set default applications for each file
extension; its File Types tab does the same across the Mac OS classical file
types, which are still supported in Lion. It also gives similarly powerful
controls over URLs, UTIs and MIME types. Other more general utilities can open
up access to these settings, but despite its age, RCDefaultApp remains the most
complete.
In your normal work, you may find all these
extensions get in the way or irritate you, in which case you can turn them off
in the Finder’s Preferences, under the advanced tool. However, if you show all
filename extensions, you should get better insight into how they work to keep
order in many important folders. Take a glance at some of the essential
components that work within OS X. In /System/Library/Extensions, for instance,
you’ll find software extensions to the kernel to support different hardware
devices, all accorded the extension of .kext, for ‘kernel extension’ and
commonly known as Kexts.
.plist files are XML Property Lists,
containing settings, preferences and the like, and are found in many Library
folders. They also feature in the Launch-Agents and Launch-Daemons folders,
containing specifications of those components that are started up
automatically, under the control of launched.