# The "dir" Package

These routines are meant to provide an enhanced, portable method for scanning directories and automatically obtaining file status information.

Library: karma
Link With: -lkarma

#### Functions

dir_open | Open a directory for reading (scanning).
dir_read | Read (scan) a directory for files.
dir_get_size | Find number of entries in a directory.
dir_close | Close a directory.
dir_rewind | Rewind a directory.

#### Tables

dir_SKIP_VALUES | List of defined skip control values

## Functions

KDir dir_open (CONST char *dirname)

Open a directory for reading (scanning).

Parameters:

- dirname : The directory name.

Returns: A KDir object on success, else NULL.
Multithreading Level: Unsafe

KFileInfo * dir_read (KDir dir, unsigned int skip_control)

Read (scan) a directory for files.

Parameters:

- dir : The directory object.
- skip_control : Determines whether or not to skip the special files: "." and "..". See dir_SKIP_VALUES for a list of legal values.

Returns: A pointer to a KFileInfo structure on success, else NULL. The data in this structure is valid until the next call to dir_read or dir_close with this directory object.
Multithreading Level: Unsafe

#### EXPERIMENTAL FUNCTION: subject to change without notice

unsigned long dir_get_size (KDir dir, unsigned int skip_control, unsigned long *max_width)

Find number of entries in a directory.

Parameters:

- dir : The directory object. This is automatically rewound.
- skip_control : Determines whether or not to skip the special files: "." and "..". See dir_SKIP_VALUES for a list of legal values.
- max_width : The maximum width of the entries is written here. This may be NULL.

Returns: The number of entries in the directory.
Multithreading Level: Unsafe

void dir_close (KDir dir)

Close a directory.

Parameters:

- dir : The directory object.

Returns: Nothing.
Multithreading Level: Unsafe

#### EXPERIMENTAL FUNCTION: subject to change without notice

void dir_rewind (KDir dir)

Rewind a directory.

Parameters:

- dir : The directory object.

Returns: Nothing.
Multithreading Level: Unsafe

## Tables

dir_SKIP_VALUES List of defined skip control values

Mode | Meaning
KDIR_DOT | Pass ".", skip ".."
KDIR_DOTDOT | Pass "..", skip "."
KDIR_DOT_AND_DOTDOT | Pass "." and ".."
KDIR_NO_DOTS | Skip "." and ".."

Back to Karma Home Page