Check out the new USENIX Web site. next up previous
Next: GNOME VFS API basics Up: Unix file system extensions Previous: The GNOME Virtual File

Extended URIs

The GNOME VFS uses an extension of the traditional web Uniform Resource Identifiers (URIs) to access files, instead of the standard Unix file paths. This enables us to access different kinds of resources in a way that is both generic and easy to understand for users.

GNOME VFS extended URIs are reminiscent of the GNU Midnight Commander's URI syntax, and consequently use the # character to stack access methods on top of each other.

In the simplest form, a GNOME VFS URI looks exactly like a normal Web URI, that is:


As in normal Web URIs, user and password are optional; in that case, the @ character will be omitted as well.

For example, the URI

will refer to the file index.html from the host through the http access method, which is an implementation of the HTTP protocol.

The access method for the local file system is called file, so, for example, the file /etc/passwd is accessed through the URI


Unlike normal Web URIs, though, GNOME VFS URIs let you ``stack'' access methods on top of each other. GNOME VFS, in fact, supports two kinds of access methods: ``toplevel'' access methods, that access files directly, and ``archive'' access methods, that access files within other files.

For example, there is a zip access method that lets you access files contained in a .zip archive file: the .zip access needs a ``parent'' access method to access the archive in which the file is contained.

Stacking is achieved in GNOME VFS URIs by using the special character #. The generic syntax is:


When this syntax is used, it specifies that sub_uri must be accessed within the file available through uri using the specified method.

For example, imagine you have a archive containing a file called bar.c. Also suppose that bar.c is contained in a directory called baz within, and that is in your home directory /home/joe. The URI to specify is:


If the file was available through FTP instead, the URI would be something like:

Some access methods don't require a subpath; for example, this is the case with the gzip access method that can be used to read and create compressed files in .gzip format.

If you wanted to read the contents of a compressed foo.gz file in your home directory, you would simply have to specify the following URI:

    file:/home/joe/foo.gz{\tt \#}gzip

By combining the gzip access method with the tar access method, it is possible to access files contained in tar.gz archives:


There is no limitation in the amount of stacking that can be performed. Every access method in GNOME VFS is implemented as a dynamically loaded plug-in, as described in section 10: anyone can extend the VFS with new access modules.

next up previous
Next: GNOME VFS API basics Up: Unix file system extensions Previous: The GNOME Virtual File
Ettore Perazzoli 2000-04-26