As noted earlier, Librep supports virtual files; that is it allows file names to be accessed that don’t reside on the local filing system, or aren’t normally valid as file names. This is achieved through the use of file handlers, Lisp functions that have signalled that they should be used to redirect all accesses to files whose names match a particular regular expression (see Regular Expressions).
For example, in Unix, a leading tilde ~ expands to the home directory. See below.
This variable contains a list of file handler declarations, each one of
(regexp . function). Whenever a file
operation is performed on a file whose name matches regexp,
function is invoked to perform the action. The function is called
(function operation args…), where
operation and args are from the original call.
For example if the
file-handler-alist contains the entry
("^~" . tilde-file-handler), then all file operations on files
starting with a tilde are redirected to the
Thus if a form
(file-exists-p "~/foo") is executed, it would
result in a call to
(tilde-file-handler 'file-exists-p "~/foo").
The list of operations that may be redirected to a file handler is:
There are several undefined functions in this list. The
insert-file-contents pertain to the Jade text editor. The other
two are defined as follows.
Called when copying files between file handlers, this operation should copy the file matching the handler file-name, to the file on the local file system local-name.
Called when copying files between file handlers, this operation should copy the local file file-name to the file matching the handler file-name.
To prevent infinite recursion, while a particular operation is being processed by a file handler, that operation may not be passed back to the same handler.
To allow file handlers to handle the
open-file operation, it is
possible to create file handles from arbitrary streams.
Return a new file object that refers to the logical file called file-name, that is not in the local filing system. All access to the file object will be directed through the stream object stream, and the file handler function handler.
An alternative method of opening remote files is to use a temporary
file in the local file system with either one (
write modes), or two (
append mode) synchronisations with
the remote system. This is the method used by the FTP remote file
backend (see the next section). It has the advantage of simplifying the
Librep provides the following file handlers by default:
In Unix, a leading tilde ~ is expanded to the user’s home directory.
Some archive files’ contents are treated like a directory, by adding ``#tar/''. For example, the file foo/bar.jl stored in /dir/baz.tar.gz can be accessed with
Supported compressions are gz with suffixes
bz2, lzma with