VFS Functions

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:

FunctionDescription
fcloseclose the file
feofcheck end of file status
fgetlread a line
fgetsread a line
fprintfwrite formatted data
freadread data
fscanfread formatted data
fseekchange the current I/O position
ftellget the current I/O position
fwritewrite data
redirectredirect output

fopen

Open a VFS file.

Syntax

fd = fopen(path)
fd = fopen(path, mode)

Description

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.

Example

fd = fopen('Data:/Measures/data.txt', 'w');
for i = 1:size(data, 1)
  fprintf('%g\t', data(i,:));
  fprintf('\n');
end
fclose(fd)

See also

vfsopen, fclose, vfsgetvolumes, vfsdir

vfsdelete

Delete a file or an empty directory.

Syntax

vfsdelete(volume, path)

Description

vfsdelete(volume,path) deletes a file or an empty directory whose absolute path is path on volume volume. Both arguments are strings.

See also

vfsdir

vfsdir

Get the list of files and directories.

Syntax

vfsdir(volume)
vfsdir(volume, directorypath)
list = vfsdir(...)

Description

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.

Example

vfsdir('Music', '/classic')
  Bach/
  Brahms/
  5th.mp3 ro

See also

vfsgetvolumes, vfsmkdir

vfsgetvolumes

Get the list of volumes.

Syntax

list = vfsgetvolumes

Description

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.

Example

vfsgetvolumes
  {'Music'}

See also

vfsdir

vfsmkdir

Make a new directory.

Syntax

vfsmkdir(volume, path)

Description

vfsmkdir(volume,path) creates a new directory whose absolute path is path on volume volume. Both arguments are strings.

Example

vfsmkdir('Music', '/mp3/classic/Bach');

See also

vfsdir

vfsopen

Open a VFS file.

Syntax

fd = vfsopen(volume, path)
fd = vfsopen(volume, path, mode)

Description

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'.

Example

fd = vfsopen('Data', '/Measures/data.txt', 'w');
for i = 1:size(data, 1)
  fprintf('%g\t', data(i,:));
  fprintf('\n');
end
fclose(fd)

See also

fopen, fclose, vfsgetvolumes, vfsdir

vfsrename

Rename a file or a directory.

Syntax

vfsrename(volume, path, newname)

Description

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.

Example

vfsrename('Pictures', '/DCIM/0003.jpg', 'jean.jpg');

See also

vfsdir


Copyright 2003-2007, Calerga.
All rights reserved.