Back to index

LispMe Virtual File System

The Virtual File System (VFS) is a layer of software of the Palm API that manages all installed file system libraries. It provides a unified API to application developers while allowing them to seamlessly access many different types of file systems -such as VFAT, HFS, and NFS-on many different types of media, including Compact Flash, Memory Stick, and SmartMedia.

Naming conventions

All pathnames are absolute and must be provided in full. Relative pathnames are not supported. All file systems support filenames and labels that are up to 255 characters long. This support includes any normal character including spaces and lower case characters in any character set. It also includes the following special characters: $ % ' - _ @ ~ ! ( ) ^ # & + , ; = [ ] When the 8.3 naming convention is used to create a filename from a long filename, the following guidelines are used. When the 8.3 convention is used to create a volume label from a long volume label the first eleven valid, non-space characters are used.

The volume name is not considered part of the path name. Instead, volumes are accessed by mount numbers, which are assigned by PalmOS when inserting a card. In principle, several volumes can be mounted at the same time, but I know of no device supporting more than one card slot. The list of currently mounted volumes can be retrieved by vfs-volumes. After ejecting and re-inserting the same memory card its volume number will have changed (incremented)

So you should normally call (car (vfs-volumes)) to retrieve the current (only?) mount number. To access a file by name, both volume number and absolute path must be specified. Should we change this and use a more complex path including the volume label? The ancient AmigaDOS did this and it worked quite well...

LispMe provides two layers to access VFS:

Low level file access

These calls are merely wrappers for the PalmOS VFS calls, which look quite similar to C file calls, like fopen(), fread(), etc. A file can be in read/write mode, you can access the attributes and timestamps, and random access via vfs-seek is possible. However, data transfer is blockwise via LispMe strings.

Access via Scheme ports

On top of the low-level file calls LispMe provides a layer which accesses VFS files as Scheme ports. All standard Scheme port functions can be used. However, when using this layer a file can be either in read or in write mode, not both.

General functions

Renaming and deleting files and creating directories works via path names and is thus independent from the latter access modes.

Pickling and unpickling

When a session is pickled, all open VFS files are closed and their opening parameters are stored, as well as the current file position. When the session is unpickled later, the files are reopened using the parameters stored with the pickled data. Thus, a running LispMe process can be interrupted (perhaps to add some DateBook entries manually) and be continued afterward seamlessly.

Associated language elements

vfs-close vfs-create-dir vfs-delete vfs-dir vfs-eof?
vfs-get-attr vfs-get-ts vfs-open vfs-open-input vfs-open-output
vfs-read vfs-ref? vfs-rename vfs-seek vfs-set-attr
vfs-set-ts vfs-size vfs-supported? vfs-tell vfs-vol-get-label
vfs-vol-info vfs-vol-set-label vfs-vol-size vfs-volumes vfs-write