Mac OS X :: File Forks
Posted: April 11, 2005

Under the Macintosh file system (called HFS, for Hierarchical File System), files are not monolithic and do not consist of one single segment. They may be composed of two pieces, called "forks"... a "data fork" and a "resource fork". The creators of the Mac's file system chose to put apart what is stored in an unique data stream on most computers. Rumor has it, however, this will be changing for efficiency's sake. Please note that NTFS also features file streams.

Data Fork
The data fork contains what we generally call a "file" on the PC (text created by a word processor, pixels that make up a picture file, etc). When transferring data files between Mac and PC, you will notice two files for every one Mac file you move (see below). The data fork file in this case is "Home Netowrk.graffle", where the resource fork is "._Home Network.graffle". The data fork is generally the only part of interest (the major exception is font files).



Resource Fork
The resource fork may contain the code of a program, the commands of a font file, etc. Some programs store a preview picture in the resource fork. The code of programs is stored in the resource fork. Program files often have an empty data fork. This explains why it can happen that a program, transferred through channels ignoring file forks and having lost its resource fork, can no longer be executed ("error -39", meaning unexpected end of file). Against what is often said, even by knowledgeable persons, the resource fork doesn't contain the signature of Mac files (file type, file creator, etc.), which is stored in the disk catalog.

Why a Resource Fork?
It makes sense to have the data fork, but why the resource fork, you may ask? The resource fork is organized as a database, which allows for a fast access to all components of the stream. This is a big advantage for some applications. It is also possible to change and replace some elements without disturbing the rest of the fork. It is also save, in most cases, it is safe to delete the resource fork file on a non-HFS volume ("._Home Network.graffle" in the case above).


Copyright © 2005 forty4.com. All rights reserved.