DirectoryListing
ptolemy.actor.lib.io.DirectoryListing

Given a URL or directory name, this actor produces an array of file names in that directory that match an (optional) pattern. The file names that are returned are absolute. The pattern is a regular expression. For a reference on regular expression syntax see: http://java.sun.com/docs/books/tutorial/extra/regex/index.html.

If directoryOrURL is a local directory (not a URL), then you can optionally list only contained files or directories. If listOnlyDirectories is true, then only directories will be listed on the output. If listOnlyFiles is true, then only files will be listed on the output. If both are true, then an exception is thrown.

If directoryOrURL is a URL, then this actor assumes that the server will list the contents of the referenced directory in an HTML file where each file listed will have the following form:

 <a href="filename">filename</a>
 
If the filename is longer than 20 characters, then only the first 20 characters of the two appearances of the filename are compared, since some servers truncate the file names.

Note that DirectoryListing returns the contents of the directory in a different order depending on whether one is using the Sun JVM or the IBM JVM. Thus, you may want to connect the output to an ArraySort actor.

Author(s): Christopher Hylands, Edward A. Lee
Version:$Id: DirectoryListing.java,v 1.33 2006/05/05 23:30:46 cxh Exp $
Pt.Proposed Rating:Yellow (eal)
Pt.Accepted Rating:Red (liuj)




directoryOrURL
The directory name or URL from which to read. This is a string with any form accepted by ptolemy.actor.parameters.FilePortParameter.

listOnlyDirectories
If true, and directoryOrURL refers to a local directory (not a URL), then only directories will be listed on the output. If directoryOrURL is a URL, then this parameter is ignored (there appears to be no reliable way to tell whether the URL refers to a directory or file). This is a boolean that defaults to false.

listOnlyFiles
If true, and directoryOrURL refers to a local directory (not a URL), then only files will be listed on the output. If directoryOrURL is a URL, then this parameter is ignored (there appears to be no reliable way to tell whether the URL refers to a directory or file). This is a boolean that defaults to false.

pattern
If non-empty, then only output file and directory names that match the specified (regular expression) pattern. The default value of this parameter is the empty String "", which indicates that everything matches.