Guardian Native C Library Calls Reference Manual (G06.28+, H06.05+)

scandir64(3) Guardian Native C Library Calls Reference Manual
NAME
scandir64 - Scan a directory
LIBRARY
G-series native OSS processes: /G/system/sysnn/zutilsrl
H-series OSS processes: /G/system/zdllnnn/zutilfdll
SYNOPSIS
#include <sys/types.h> /* optional except for POSIX.1 */
#include <dirent.h>
int scandir(
const char *dir_name,
struct dirent64 *(*namelist[]),
int (*select)(struct dirent64 *entry),
int (*dcomp)(struct dirent64 **entry1,
struct dirent64 **entry2));
PARAMETERS
dir_name Names the directory.
namelist Points to an array of structure pointers.
select Function with a directory entry as its parameter
dcomp Function with two directory entries as its parameters.
DESCRIPTION
The scandir64() function is similar to the scandir( ) function except that, in addition to support-
ing smaller les, the scandir64() function supports les larger than approximately 2 gigabytes.
An application can explicitly call this function when you compile the application using the
#define _LARGEFILE64_SOURCE 1 feature test macro or an equivalent compiler command
option.
An application call to scandir( ) is automatically mapped to this function when you compile the
application using the #define _FILE_OFFSET_BITS 64 feature test macro or an equivalent
compiler command option.
The scandir64() function reads the directory designated by the dir_name parameter and builds
an array of pointers to copies of selected entries.
The scandir64() function returns the number of entries selected. In addition, a pointer to the
array of addresses of selected entries is assigned to the pointer referenced by the second parame-
ter. The value -1 is returned when the directory named by the dir_name parameter cannot be
accessed or when not enough memory is available to hold the copies of directory entries or the
array of their addresses. (In this case the address value in the pointer referenced by the second
parameter is not changed.)
The select() function is called for each entry in the dir_name directory. It returns a non-zero
value if and only if the entry is to be selected (have a copy made). If a null pointer is supplied for
this parameter, every directory entry is selected.
The nal array of addresses of copied entries is sorted by calling qsort(). The dcomp( ) function
is passed to qsort() as the comparison function. If a null pointer is supplied for this parameter,
the array is not sorted.
When the information created by a call to scandir64() is no longer needed, return the data
resource it occupies by calling free() for each address in the array and then calling free() with
the address of the array itself.
66 Hewlett-Packard Company 527192-007