Read directory contents given the path and file pattern to search for.
File or directory names will be returned in the order dictated by the
operating system and cannot be changed. However, names returned with
the List methods will always be in alphanumeric order.
If the given path does not exist or if a directory cannot be opened for
reading, return undef.
Uses the built-in perl functions 'opendir', and 'readdir'.
object = new ReadDir(ipath,(optional file extension list))
Open a directory for reading and create a new directory object. Returns
the object reference. ARG1 is the initial path.
ARG2 is optional list of file extensions or file types to be included in
subsequent file lists. List is not case sensitive. List may also be set
using the Ext method.
An empty ARG2 list will cause all file types to be included in subsequent
file lists.
Current path (cPath) is set to initial path when first opended.
Set or return current path. This differs from the initial path in that
the current path must be directly under the initial path. This allows
all subdirectories under the initial path to be examined with subsequent
cPath and Pop statements. Does not affect the current directory of the
Perl environment.
When changing the current path, the current directory information is saved.
Uppon returning to this directory, the file and subdirectory pointers
will be returned to their original positions.
$currpath = $D->cPath;
In the context of returning the current path, the entire path string
starting from the initial path will be returned.
$currpath = $D->cPath('bender');
In the context of setting the current path, the entire path starting
with the initial path will be returned if successful. Return empty
scalar if not.
Set or return list of file extensions or file types to be included in
subsequent file lists. List is not case sensitive. List may also be set
during object creation. An empty FileExt list will cause all file types to be included
in subsequent file lists.
@extlist = $D->FileExt; # return list of file types
$D->FileExt( 'htm', 'html' ); # Set list of file types
Define a pattern for file searching or return the current pattern string.
Uses a regular expresion. The filename pattern will be applied to the list
of file types that were defined in the FileExt or object creation methods.
Using a blank argument will reset the pattern.
$D->FilePattern('\..*htm.*$'); # find all html files
$D->FilePattern(''); # reset pattern
$pat = $D->FilePattern; # return current pattern
Note: In pattern matching, case is always ignored.
Define a pattern for file searching or return the current pattern string.
Uses a regular expresion. The subdirectory pattern will be applied to the
list of subdirectories in the current path.
Using a blank argument will reset the pattern.
$D->SubPattern('^foo'); # find all subdirectories that
# begin with "foo"
$D->SubPattern(''); # reset pattern
$pat = $D->SubPattern; # return current pattern
Note: In pattern matching, case is always ignored.