<< Previous | Next >>

fat_ReadDir

int fat_ReadDir( FATfile *dir, fat_dirent *entry, int mode );

Description

Reads the next entry of the desired type from the given directory, filling in the entry structure.

Parameters

dir
Pointer to the handle for the directory being read.

entry
Pointer to the handle to the entry structure to fill in.

mode
0 = next active file or directory entry including read only (no hidden, sys, label, deleted or empty)

A nonzero value sets the selection based on the following attributes:

· FATATTR_READ_ONLY - include read-only entries
· FATATTR_HIDDEN - include hidden entries
· FATATTR_SYSTEM - include system entries
· FATATTR_VOLUME_ID - include label entries
· FATATTR_DIRECTORY - include directory entries
· FATATTR_ARCHIVE - include modified entries
· FAT_FIL_RD_ONLY - filter on read-only attribute
· FAT_FIL_HIDDEN - filter on hidden attribute
· FAT_FIL_SYSTEM - filter on system attribute
· FAT_FIL_LABEL - filter on label attribute
· FAT_FIL_DIR - filter on directory attribute
· FAT_FIL_ARCHIVE - filter on modified attribute

The FAT_INC_* flags default to FAT_INC_ACTIVE if none set:

· FAT_INC_DELETED - include deleted entries
· FAT_INC_EMPTY - include empty entries
· FAT_INC_LNAME - include long name entries
· FAT_INC_ACTIVE - include active entries

The following predefined filters are available:

· FAT_INC_ALL - returns ALL entries of ANY type
· FAT_INC_DEF - default (files and directories including read-only and archive)
NOTE Active files are included by default unless FAT_INC_DELETED, FAT_INC_EMPTY, or FAT_INC_LNAME is set. Include flags become the desired filter value if the associated filter flags are set.

Examples of Filter Behavior

mode = FAT_INC_DEF | FATFIL_HIDDEN | FATATTR_HIDDEN

would return the next hidden file or directory (including read-only and archive)

mode = FAT_INC_DEF|FAT_FIL_HIDDEN|FAT_FIL_DIR|FATATTR_HIDDEN

would return next hidden directory (but would not return any hidden file)

mode = FAT_INC_DEF|FAT_FIL_HIDDEN|FAT_FIL_DIR|
       FATATTR_HIDDEN & ~FATATTR_DIRECTORY

would return next hidden file (but would not return any hidden directory)

mode = FAT_INC_ALL & ~FAT_INC_EMPTY

would return the next non-empty entry of any type

Return Value

0: success.
-EINVAL: invalid argument.
-ENOENT: directory does not exist
-EEOF: no more entries in the directory
-EFAULT: directory chain has link error
-EBUSY: the device is busy (non-blocking mode only)

Other negative values from the fat_Open() call are also possible.

Library

FAT.LIB

See Also

fat_OpenDir, fat_Status


Dynamic C Functions << Previous | Next >> rabbit.com