The Virtual File System (VFS) enables the operating system to support different kinds of file systems. It is available in Palm OS 4 and later. For flash memory cards, the VFAT format is used. Multiple formats can coexist on the same handheld.
VFS files and directories are identified with two strings: the volume name and the full path. This differs from other file systems where the path contains enough information to identify the volume. LyME provides two functions for opening a file: vfsopen, with separate volume name and path; and fopen, compatible with other LME applications like Sysquake.
Functions directly related to VFS are described below. Input, output, and control are done with the following generic functions:
Function | Description |
---|---|
fclose | close the file |
feof | check end of file status |
fgetl | read a line |
fgets | read a line |
fprintf | write formatted data |
fread | read data |
fscanf | read formatted data |
fseek | change the current I/O position |
ftell | get the current I/O position |
fwrite | write data |
redirect | redirect output |
Open a VFS file.
fd = fopen(path) fd = fopen(path, mode)
fopen(path) opens the file specified by string path on the first volume, in read-only mode. The argument contains either the full path of the file on the first volume, or the volume name and the full path separated with a colon (e.g. 'card:/dir/file.txt').
fopen(path,mode) opens a file in read-only mode if mode is 'r', or in read-write mode if mode is 'w'. mode can have a second character which is ignored, for compatibility with other versions of fopen.
fd = fopen('Data:/Measures/data.txt', 'w'); for i = 1:size(data, 1) fprintf('%g\t', data(i,:)); fprintf('\n'); end fclose(fd)
vfsopen, fclose, vfsgetvolumes, vfsdir
Delete a file or an empty directory.
vfsdelete(volume, path)
vfsdelete(volume,path) deletes a file or an empty directory whose absolute path is path on volume volume. Both arguments are strings.
Get the list of files and directories.
vfsdir(volume) vfsdir(volume, directorypath) list = vfsdir(...)
vfsdir(volume) displays the list of files and directories at the root level of volume volume. Hidden files are not displayed. Directories are followed with a slash ('/'); read-only files, with 'ro'; system files, with 's'; and links, with 'l'.
vfsdir(volume,directorypath) displays the list of files and directories in the directory directorypath of volume volume. Both arguments are strings. The directory path must be absolute (it begins with a slash).
With an output argument, vfsdir returns the result in a list of structures. Each element corresponds to a file or a directory in the specified location. Hidden elements are also included. Structure fields include name, the file or directory name (a string), and logical values for the element attributes: readonly, hidden, system, volumelabel, directory, archive, and link.
vfsdir('Music', '/classic') Bach/ Brahms/ 5th.mp3 ro
Get the list of volumes.
list = vfsgetvolumes
vfsgetvolumes gets the list of all volumes available on the handheld. Volumes are identified by their name (a string). They are used with the path to identify a directory or a file in VFS.
vfsgetvolumes {'Music'}
Make a new directory.
vfsmkdir(volume, path)
vfsmkdir(volume,path) creates a new directory whose absolute path is path on volume volume. Both arguments are strings.
vfsmkdir('Music', '/mp3/classic/Bach');
Open a VFS file.
fd = vfsopen(volume, path) fd = vfsopen(volume, path, mode)
vfsopen(volume,path) opens the file whose absolute path is path on volume volume, in read-only mode. Both arguments are strings.
vfsopen(volume,path,mode) opens a file in read-only mode if mode is 'r', or in read-write mode if mode is 'w'.
fd = vfsopen('Data', '/Measures/data.txt', 'w'); for i = 1:size(data, 1) fprintf('%g\t', data(i,:)); fprintf('\n'); end fclose(fd)
fopen, fclose, vfsgetvolumes, vfsdir
Rename a file or a directory.
vfsrename(volume, path, newname)
vfsrename(volume,path,newname) changes the name of the file or directory whose absolute path is path on volume volume to newname. All arguments are strings.
vfsrename('Pictures', '/DCIM/0003.jpg', 'jean.jpg');