GnomeVFS - Filesystem Abstraction library | |||
---|---|---|---|
<<< Previous Page | Home | Up | Next Page >>> |
In the GNOME Virtual File System, the implementations for all the access methods are loaded at runtime, as shared library modules. The modules are loaded during parsing of the string URI: if the parser encounters an access method for which no implementation is currently loaded, it retrieves the corresponding library file, dynamically links it into the executable, and initializes it.
After initialization, the module returns a special GnomeVFSMethod object that contains pointers to the various implementation functions for that specific method. By storing a pointer to this object into the GnomeVFSURI type, the VFS library is then able to use these functions for file access.
When the VFS library needs to perform some file operation, it performs the following steps:
If the URI is given in textual form (i.e. as a string), it parses it and activates the necessary access method modules.
It retrieves a pointer to the lowmost level URI element.
It retrieves a pointer to the GnomeVFSMethod object that corresponds to the access method for that URI element.
It retrieves a pointer to the implementation function for that operation from the GnomeVFSMethodobject.
It invokes that implementation function passing the pointer to the lowmost level URI element.
Combining the access methods is always done within the method implementation. If the method implementation needs to do some file operation on the the parent URI element, it can do so by simply invoking the corresponding VFS function in, by using the parent pointer in the GnomeVFSURI object.
For example, suppose you have to read a simple URI like the following:
file:/home/ettore/file.gz#gzip |
In this case, the GZIP method will be invoked with a pointer to the GnomeVFSURI describing the `gzip' part; then the GZIP method will be able to read file.gz by just invoking the corresponding GNOME VFS library function on its parent, and decompress it on the fly.
<<< Previous Page | Home | Up | Next Page >>> |
Writing modules for the GNOME Virtual File System | Implementing an access method in practice |