# vfs.list

function

 Library: File system utilities (OMVFS) Import : omvfs.xmd

Declaration
export external function list
matching value string match optional initial {'*'}
on      value directory on-dir optional
into    write-only string names
include value integer include optional initial {all-contents}



Argument definitions

matching
The path of the directory whose content is to be listed, followed by the selection criteria. The default selection criteria is '*'
on- dir
A connected vfs.directory object. If this parameter is specified, the matching parameter is evaluated relative to the vfs.directory object and must be expressed as a relative URL, followed by the selection criteria.
names
A string or stream shelf of variable size into which the list will be written.
include
A constant indicating whether the list should include files, directories, or both.

Purpose

You can use vfs.list to list the files and/or directories in a directory. The results are returned as the items in a string shelf. The following program lists all the xml files in a directory:

   import "omvfs.xmd" prefixed by vfs.
process
local string listing variable
vfs.list matching "c:\foo\bar\*.xml"
into listing
include vfs.all-files
repeat over listing
output listing || "%n"
again


To list the files in the current working directory, simply specify the selection criteria alone without the path information:

   import "omvfs.xmd" prefixed by vfs.
process
local string listing variable
vfs.list matching "*.xml"
into listing
include vfs.all-files
repeat over listing
output listing || "%n"
again


The include must be one of the following values:

• all-files
• all-directories
• all-contents

### Exceptions

The following exceptions may occur:

• VFS001 The requested function is not supported for the type of connection
• VFS004 The specified name 'X' exceeds system length limits
• VFS100 The vfsDir object must be connected before it can be used
• VFS105 The path 'X' is not a valid absolute or relative path
• VFS109 An invalid value was specified for the content type include indicator
• VFS111 The URL 'X' contains invalid encoding
• VFS300 Generic operating system error

### Troubleshooting

The precise wildcard matching algorithm used is platform dependent, and thus a given file pattern may match a slightly different set of files on different platforms in some cases. For instance, the selection criteria "*.xml" will match a file named "foo.xmlx" on Windows but not on UNIX.

Related Topics
Other Library Functions