[e-lang] File API taming

Kevin Reid kpreid at mac.com
Fri Mar 20 00:11:26 EDT 2009

On Mar 19, 2009, at 21:52, Sam Mason wrote:

> Extrapolating a bit to what would appear to be an awkward case; how
> would a program handle files that have references out to other files?
> The most widely known example I'd know would be an HTML document and
> the images, CSS and other miscellanea it happens to refer to.  Or even
> further to other file formats I've come across where you have a "data"
> file that contains unstructured data and a "header" file that defines
> the structure of the data.  These files were assumed to have the same
> name, with the data file ending in ".bin" and the header ".hdr".

I wrote a bit about the problem of mapping these inter-file  
relationships into a capability filesystem, in the specific case of  
HTML, in the following message to cap-talk.

Suppose I have a Cap Desktop with a cap filesystem. In this filesystem
I store a HTML document and the items linked or embedded: images,
stylesheets, other pages...

How does that document refer to the other items? In web language, what
is the base URL for its relative URLs? How does the web browser
acquire the appropriate file-caps?

It is obviously inappropriate in a capability environment for the
document to get access to a containing directory, and the web browser
may not even have that access.

My conclusion is that the file object which stores the HTML text also
has a component which is a directory of the other file-caps which this
document may refer to. That is, the file object is like

    content:     '...<img src="foo.gif">...',
    local_names: {
      "foo.gif": <cap to image file>,

(This is essentially the same as a closure: "content" is the
"program", and "local_names" is the closed-over bindings, and all the
relative URLs become "lambda names" as MarkM would say. There is no
encapsulation, unless we define some universal-to-our-platform
interpretation of HTML to use.)

In this situation, the web browser gets the HTML and the namespace,
and when the HTML+JS looks up a name (whether statically or
dynamically), it is looked up in the local_names directory.

This system should work transparently as long as there is no
communication of URLs between documents -- which would be equivalent
to passing a lambda name or clist index to another program/process.
There might be schemes to make this work, such as making a set of
related documents explicitly share a namespace.

Kevin Reid                            <http://homepage.mac.com/kpreid/>

More information about the e-lang mailing list