NAME ^

Parrot::IO::Directory - Directory

SYNOPSIS ^

        use Parrot::IO::Directory;

DESCRIPTION ^

Use this to query and manipulate directories and their contents.

Class Methods ^

directory_class()

Returns the class used in the various directory creation methods. This default implementation returns Parrot::IO::Directory.

file_class()

Returns the class used in the various file creation methods. This default implementation returns Parrot::IO::File.

directory_with_path($path)

Returns the directory with the specified path.

The directory is an instance of the class returned by directory_class.

file_with_path($path)

Returns the file with the specified path.

The file is an instance of the class returned by file_class.

tmp_directory($path)

Returns the directory for $path relative to the default temporary directory.

new($path)

Returns the instance for specified path.

Instance Methods ^

create_path()

This is called from new() to create the path if necessary.

relative_path($directory)

relative_path($file)

relative_path($path)

Returns the specified path relative to the directory.

parent()

Returns the directory's parent directory. The root directory returns undef.

file_and_directory_names()

These are the names of all the files and subdirectories in the directory.

file_and_directory_paths()

These are the full paths of all the files and subdirectories in the directory.

file_paths()

These are the full paths of all the files in the directory.

directory_paths()

These are the full paths of all the subdirectories in the directory.

file_exists_with_name($name)

Returns whether a file with the specified name exists in the directory.

directory_exists_with_name($name)

Returns whether a subdirectory with the specified name exists in the directory.

files($recursive, $ignore)

This gives you an array of Parrot::IO::File instances.

Set $recursive to true if you want all files in subdirectories to be included. To ignore everything below particular directories use a regex in $ignore.

directories()

This gives you an array of instances of the same class as the directory itself.

file_suffixes($recursive, $ignore)

Use this to get an array of the file type suffixes used for files in the directory.

$recursive and $ignore function as specified above for files().

For example:

    $parrot->file_suffixes(1, '^(CVS|icu)$');
will give you all the suffixes used in Parrot ignoring all CVS and ICU files.

Note that if there are files with no suffix then the empty string will be included in this list.

files_with_suffix($suffix, $recursive, $ignore)

Use this to get a list of the files with a particular suffix.

$recursive and $ignore function as specified above for files().

Note that if $suffix is the empty string then this will return all the files with no suffix.

path_for_directory_with_name($name)

Returns the path for the subdirectory with the specified name in the directory.

path_for_file_with_name($name)

Returns the path for the file with the specified name in the directory.

directory_with_name($name)

Returns a directory with the specified name in the directory.

file_with_name($name)

Returns a file with the specified name in the directory.

existing_directory_with_name($name)

Returns a directory with the specified name in the directory.

existing_file_with_name($name)

Returns a file with the specified name in the directory.

path_for_directory_with_relative_path($path)

Returns the path for the subdirectory with the specified path taken relative to the directory.

path_for_file_with_relative_path($path)

Returns the path for the file with the specified with the specified path taken relative to the directory.

relative_path_is_directory($path)

Returns whether the specified relative path is a directory.

relative_path_is_file($path)

Returns whether the specified relative path is a file.

directory_with_relative_path($path)

Returns a directory with the specified relative path below the directory.

file_with_relative_path($path)

Returns a file with the specified relative path below the directory.

delete()

Deletes the directory and all its contents, removes the instance from the cache, and undefines it.

Raises an exception if the delete fails.

delete_contents()

Deletes the contents of the directory.

Raises an exception if the delete fails.

SEE ALSO ^

Parrot::IO::File

Parrot::IO::Path


parrot