Next: , Previous: , Up: Top   [Contents][Index]


1 Storage on the file system

You can read and write resources on the file system with the (pissenlid file-system).

exception: &resource-does-not-exist-error

This is the type of the exceptions that are raised when a resource is queried, but it does not exist on the file system.

exception: &resource-representation-does-not-exist-error

When you request a resource representation with a certain content-type, but that content-type does not exist, this error is raised.

predicate: resource-does-not-exist-error? error
predicate: resource-representation-does-not-exist-error? error

Check that error is of type &resource-does-not-exist-error (respectively &resource-representation-does-not-exist-error).

A resource has different linked data types. The most important types are http://www.w3.org/ns/ldp#Resource, which is the base type of a resource, and http://www.w3.org/ns/ldp#BasicContainer, for containers.

function: read-types path

Return the list of type URIs of a resource identified by path. path should be the path of an URI.

function: write-types path types

Set the types (a list of URIs) of the resource identified by path.

If the resource is a container, you might want to get the list of contained resources.

function: list-containers path

Return the list of resource paths that are contained within the resource identified by path.

In fact, resources can contain other resources regardless of their types. This means that there is a natural hierarchy of resources.

function: parent-resource path

Return the resource path of the resource that contains the resource identified by path.

If you want to create a resource under a container, you need not edit anything for the container, just create the resource.

function: create-resource parent types slug

Create a new resource with the given types under the parent container. The resource is named slug. If such a resource already exists, simply update its types.

function: delete-resource path

Delete the resource identified by path, and every resource contained within that resource.

In order to know who has access to the resource, each one has an access control list (ACL), whose format is not specified here. This is a simple file, that you can open for reading or writing. Every resource has an ACL. If you want to simulate that a resource inherits the ACL of its parent, just write that in the ACL.

function: open-acl path mode . args

Open the ACL of the resource identified by path with the given mode (and pass the further args to open-file).

The resource in itself can have multiple different representation, each with its own content type.

function: list-content-types path

Return a list of content types of the resource identified by path. The content types are symbols, like 'application/json or 'text/turtle.

function: set-content path content-type binary
function: get-content path content-type binary?

For set-content, create a new representation with the given content-type for the resource identified by path, or replace the representation with that content-type. For get-content, open the representation with the given content-type. Return a new open port to that file, opened in textual mode or binary mode.

function: delete-content-type path content-type

Remove the representation of the resource identified by path with the given content-type.

Resource representations have an “ETag”, which is a small piece of information that is updated every time the resource representation changes.

function: get-etag path content-type

Get the ETag of the representation with the given content-type of the resource identified by path.

function: change-etag path content-type

Change the ETag of the representation with the given content-type of the resource identified by path. It is a new random value.


Next: , Previous: , Up: Top   [Contents][Index]