class Directory

This class provides a means for accessing a directory for reading

Description

Do not create instances of this class directly. The way to read a directory is to use the Directory.open or Directory.listing functions which will create an instance and return it for you.

class contents [NB. Highlighted attributes are static members]
Functions
function close() - You should call this function when you have finished reading
function constructor(string) - The constructor for a Dir object
function getCurrent() - Get the current working directory
function getEntry() - Reads a file name from the directory stream
function make(string,number) - Create a directory with the given modes
function open() - Create a directory object, open a directory and return the object for use.
function remove(string,number) - Remove a directory from the system
function setCurrent(string) - Change the current working directory to the path specified
function toArray() - Creates an array from the list of files in this directory

Functions

function close Click to go up to the list
You should call this function when you have finished reading
Declaration:
    function close()
Returns:
    true on success, false otherwise

function constructor Click to go up to the list
The constructor for a Dir object
Declaration:
    function constructor(string directory)
Description:
This function is the constructor for the Directory class. You should supply it with the name of the directory you wish to read the file names from. You may then either call the toArray() method to generate an array of filenames in one step or repeatedly call the readdir() to read the file names one at a time. To "rewind" to the beginning or to read another directory without creating a new Dir object, call constructor again and the directory stream will be closed and reopened.
Parameters:
    Parameter #1: string directory - The path to the directory to read from

static function getCurrent Click to go up to the list
Get the current working directory
Declaration:
    static function getCurrent( )
Returns:
    The current working directory as a string

function getEntry Click to go up to the list
Reads a file name from the directory stream
Declaration:
    function getEntry()
Description:
This function reads the next file name from this directory stream object and returns it as a string. On error, an empty string is returned and err.number is set to the system error number (which is always greater than 0). When there are no more files left to read, an empty string is returned and err.number is set to 0.

static function make Click to go up to the list
Create a directory with the given modes
Declaration:
    static function make( string dirname, number mode )
Description:
This creates a directory using the octal modes supplied like File.create
Parameters:
    Parameter #1: string dir - The name of the directory to create
    Parameter #2: number mode - The modes to create it with
Returns:
    'true' on success, 'false' otherwise and err.str will be set with the error

static function open Click to go up to the list
Create a directory object, open a directory and return the object for use.
Declaration:
    static function open( string directory )
Description:
If this function is given a closure, it will itterate over the directories entries, pasing each one to the closure.
Returns:
    A directory object on success if no closure, null otherwise

static function remove Click to go up to the list
Remove a directory from the system
Declaration:
    static function remove( string path, number recursive )
Parameters:
    Parameter #1: string path - The directory to remove
    Parameter #2: number recursive - Whether to recursively remove the contents of the directory
Returns:
    true on success, false otherwise.

static function setCurrent Click to go up to the list
Change the current working directory to the path specified
Declaration:
    static function setCurrent( string path )
Parameters:
    Parameter #1: string path - The path to change to
Returns:
    'true' on success, 'false' otherwise and err.str will be set with the error

function toArray Click to go up to the list
Creates an array from the list of files in this directory
Declaration:
    function toArray()
Description:
This function returns an array of strings containing the names of the files in the directory this Dir object points to. You should either call this function or repeatedly call the readdir() function, not both. You can only call toArray() once unless you call the constructor again to reopen the directory stream.

Automatically generated at 12:07PM, Wednesday 25 May 2005 by feritedoc.