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

Options

Description

Examples

Compatibility

Calling Sequence

ListDirectory(dir, opts )

Parameters

dir

-

path to the directory to be displayed

opts

-

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

Options

• 

ListDirectory accepts these optional arguments: absolute, all, long, and returnonly.

• 

absolute= truefalse

  

Specifying absolute=true causes ListDirectory to return absolute paths for all listed files (see AbsolutePath). With the default value absolute=false, only the filenames themselves are returned.

• 

all= truefalse

  

By default, ListDirectory does not include filenames that begin with "." in its list of results. Specifying the all option causes ListDirectory to include these files.

• 

depth= posint or infinity

  

Specifying depth with a value other than 1 causes ListDirectory to recursively traverse the complete directory tree starting with dir to the depth specified by depth.

  

Note that if depth is set to a value other than 1, the value of option absolute is implicitly set to true, and the special directories "." and ".." will not appear in the list of results even if all=true was specified.

  

Specifying depth=infinity is equivalent to specifying recurse=true.

• 

long= truefalse

  

Specifying long causes ListDirectory to returns a DataFrame structure which contains the name together with additional properties about each file, including size, whether or not the file is a directory, access permissions, and last modification date. The default is false.

• 

recurse= truefalse

  

Specifying recurse=true causes ListDirectory to recursively traverse the complete directory tree starting with dir. The default is false.

  

Note that if recurse=true, the value of option absolute is set to true, and the special directories "." and ".." will not appear in the list of results even if all=true was specified.

  

Specifying recurse=true is equivalent to specifying depth=infinity.

• 

returnonly= string

  

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

Description

• 

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

• 

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

DataDirectoryFileToolsJoinPathdata,base=mapledir

DataDirectory/usr/local/repository/build/rdgetroll8/maple/slot0/data

(1)

FileToolsListDirectoryDataDirectory

CAD,Excel,GroupData,SQLite,Workbook,assistants,audio,datasets,dsolve,eBookTools,example,finance,help,images,plotting,portal,q,sigpro,stylesets,tutors,videos,xls,xml,xsl,zoneinfo,ks.txt,ThermophysicalData

(2)

FileToolsListDirectoryDataDirectory,'all'

.,..,CAD,Excel,GroupData,SQLite,Workbook,assistants,audio,datasets,dsolve,eBookTools,example,finance,help,images,plotting,portal,q,sigpro,stylesets,tutors,videos,xls,xml,xsl,zoneinfo,ks.txt,ThermophysicalData

(3)

FileToolsListDirectoryDataDirectory,'all','returnonly'=f*

finance

(4)

FileToolsListDirectoryDataDirectory,'returnonly'=*[ae]*

Excel,GroupData,SQLite,assistants,audio,datasets,dsolve,eBookTools,example,finance,help,images,portal,stylesets,videos,zoneinfo,ThermophysicalData

(5)

FileToolsListDirectoryDataDirectory,'all','returnonly'=*[ae]*

Excel,GroupData,SQLite,assistants,audio,datasets,dsolve,eBookTools,example,finance,help,images,portal,stylesets,videos,zoneinfo,ThermophysicalData

(6)

FileToolsListDirectory/home/maple/m/foo1.m

Error, (in listdir) directory does not exist

FileToolsListDirectory/home/maple/noexist

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

Compatibility

• 

The FileTools[ListDirectory] command was updated in Maple 2018.

• 

The depth, long and recurse options were introduced in Maple 2018.

• 

For more information on Maple 2018 changes, see Updates in Maple 2018.

See Also

file

FileTools[AbsolutePath]

FileTools[Binary][Open]

FileTools[IsDirectory]

FileTools[Text][Open]

IO_errors

StringTools[WildcardMatch]