FileTools - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Input and Output : File Manipulation : FileTools : FileTools/ListDirectory

FileTools

  

ListDirectory

  

display the contents of a directory

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

ListDirectory(dir, opt1, opt2, ...)

Parameters

dir

-

path to the directory to be displayed

opt1, opt2, ...

-

(optional) argument of the form option or option=value where option is one of absolute, all, or returnonly

Description

• 

The ListDirectory(dir) calling sequence returns the contents of the directory dir as a list.

• 

ListDirectory accepts three optional arguments: absolute, all, and returnonly.

  

absolute or absolute = true/false

  

Returns absolute paths for the listed files (see AbsolutePath).

  

all or all = true/false

  

By default ListDirectory does not display filenames that begin with ".". Specifying the all option makes ListDirectory consider these files as well.

  

returnonly = string

  

The string argument is used to select elements from the list of filenames. Only the filenames that match the pattern specified in the string are returned. Patterns of the form defined by StringTools[WildcardMatch] are used.

• 

If dir does not exist, ListDirectory generates an error.

• 

If dir is not a directory, ListDirectory generates an error.

• 

For information on filenames, see file.

Examples

FileTools[ListDirectory]/home/maple/m

foo1.m,foo2.m,xbar.m

(1)

FileTools[ListDirectory]/home/maple/m,'all'

.,..,.hidden,foo1.m,foo2.m,xbar.m

(2)

FileTools[ListDirectory]/home/maple/m,'all','returnonly'=f*

foo1.m,foo2.m

(3)

FileTools[ListDirectory]/home/maple/m,'returnonly'=*[ae]*

xbar.m

(4)

FileTools[ListDirectory]/home/maple/m,'all','returnonly'=*[ae]*

.hidden,xbar.m

(5)

FileTools[ListDirectory]/home/maple/m/foo1.m

Error, (in listdir) directory does not exist

FileTools[ListDirectory]/home/maple/noexist

Error, (in isdir) file or directory does not exist

See Also

file

FileTools[AbsolutePath]

FileTools[Binary][Open]

FileTools[IsDirectory]

FileTools[Text][Open]

IO_errors

StringTools[WildcardMatch]