[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What is a FORKED file?



<icssofty@aol.com> wrote:

> Forked files are those which contain two separate sets of data (or forks).
>  On one side you have the data fork (actual program instruction code), and
> on the other you have the resource fork (variables used in the instruction
> code).

That is a somewhat simplified description.  In case anyone is interested
in more detail:


At the file system level, a forked file is basically two files which are
attached to the same directory entry (with a single name, file type,
modification date/time, etc.)  Programs can access either fork using
standard operating system calls (in GS/OS and MacOS, at least).  As long
as you use a smart enough copy program, both forks should be transferred
when you copy or move the file.


ProDOS-8 was never updated to handle forked files.  Any attempt to
access the contents of the file will result in an "unknown storage type"
error (probably displayed as "FILE TYPE MISMATCH" by BASIC.SYSTEM).  It
is not even possible to access the data fork (the "normal" part of the
file).

There is one exception to this: ProDOS-8 can access the data fork of a
forked file on an AppleShare server (or a Mac which is running File
Sharing), and applications can also access the resource fork by making
special calls.


The data fork is the traditional part of the file.  It can be used for
anything, and the interpretation of its content depends on the file
type.

For a GS/OS or PowerPC MacOS application, the data fork contains the
application code (or at least part of it).  For a 68K MacOS application,
the data fork is not used.


The resource fork is nearly always used to hold resources, which are
separate pieces of data that have a type and identification number
associated with them (and an optional name).  The "Resource Manager"
toolset on the IIgs and Mac deals with the internal organisation of the
resource fork, and applications make calls to the Resource Manager or
higher level toolsets to access individual resources.

(There are significant differences in the internal organisation of the
resource fork between the Macintosh and IIgs.  The IIgs and Mac Resource
Managers provide a similar set of calls, but they are not identical.
Neither Resource Manager is able to deal with resource forks created by
the other one, but simple copying of the file via the operating system
is no problem.)

In an application, the resource fork is commonly used to hold
definitions for the application's user interface (menus, dialog boxes,
etc.)  The resources can be modified without having to recompile the
application.  This modification can be done by the programmer or by the
end user.

One major use of this is for setting up international versions of
software: as long as all text is stored in resources, they can all be
changed to another language as required.

For a 68K MacOS application, the application code is also stored in
resources.  GS/OS and PowerPC MacOS applications can also have code
stored in this manner (though it is harder to manage).

In files other than applications, resources are used for a wide variety
of purposes.  Some examples on the IIgs:

- In a "Teach" file, the style information is held in resources, while
the text goes in the data fork.

- In a Control Panel (CDEV), several special resources are used to
provide information to the Control Panel NDA, and the code for the CDEV
is stored in a resource.

- Any file may have a Comment resource attached to it.

- The "Desktop" file managed by Finder contains resources collected from
applications for file icons and file type ownership.


Resources are an optional feature for applications on the IIgs.  They
were added in System 5.0 (System 4.0 supports forked files, but has no
Resource Manager, and its Finder doesn't even know to copy the resource
fork).  The author of the program can decide whether or not they will
make use of resources.

-- 
David Empson
dempson@actrix.gen.nz
Snail Mail: P.O. Box 27-103, Wellington, New Zealand