Experimental Lamp supports resource maps as directories

12 views
Skip to first unread message

Joshua Juran

unread,
Nov 7, 2010, 10:44:47 PM11/7/10
to classic...@googlegroups.com
The current experimental snapshot of Lamp (20101107-1948 and later)
has improvements to the support of resource maps.

Lamp (Lamp ain't Mac POSIX)
http://www.metamage.com/lamp/

First, let me define some terms: The resource fork is a counterpart
to the data fork. It's one of the two byte streams associated with
every HFS file (though possibly empty, i.e. zero-length).

A resource map is a data structure containing resources that
traditionally has lived in the resource fork, though OS X introduced
data fork resource maps. An empty resource map (i.e. one containing
no resources) occupies 286 bytes.

Lamp continues to support the filing construct "file/rsrc" as OS X
does -- it refers to file's resource fork. It always exists if file
does (though it may be empty).

Lamp also supports "file/r" (formerly "file/res") to refer to a
resource map within file's resource fork. If the resource fork is
empty, then file/r doesn't exist and can be created with mkdir.
Otherwise file/r is a directory containing zero or more files of the
form xxxx.TYPE or xxxx-resource_name.TYPE, where xxxx is a 16-bit
resource ID in hexidecimal. If file/r is empty, then `rmdir file/r`
will truncate the resource fork.

The entries for resources can be opened, read, written, truncated,
appended, and deleted just like any other file. (Support for renaming
resources is still in progress.)

Additionally, if a file has an empty data fork, a type of 'rsrc', and
a name ending in ".rsrc:" (which is ".rsrc/" in the Finder), then Lamp
treats it as a resource map directory. The difference between file/r
and file.rsrc: is that the first one is not reachable by walking the
parent directory -- file will just show up as a regular file, whereas
file.rsrc: will stat as a directory. The latter usage is designed to
interact well with Git, and so far this appears to work. This means
that a Mac programmer can keep resources in a resource file and edit
them with ResEdit, and store them in Git as distinct objects (which
will be checked out as separate files on a non-Lamp system).

I hope someone finds this useful. ;-)

Josh


Reply all
Reply to author
Forward
0 new messages