scandir(), scandir64()

scan directory 

Function


SYNOPSIS

#include <dirent.h>

int scandir(const char *dirname, struct dirent ***namelist, int (*select)(struct dirent *), int (*compar)(const void *, const void *));

int scandir64(const char *dirname, struct dirent64 ***namelist, int (*select)(struct dirent64 *), int (*compar)(const void *, const void *));


DESCRIPTION

The scandir() function reads the directory dirname and uses malloc() to build an array of pointers to directory entries. The namelist parameter specifies a pointer to an array of structure pointers which is updated to reflect the directory entries scanned by scandir().

select is a pointer to a routine which is called with a pointer to a directory entry and should return a non-zero value if the directory entry should be included in the array pointed to by namelist. If select is NULL, all the directory entries are included. The last argument compar is a pointer to a routine which is passed to qsort() to sort the completed array. If this pointer is NULL, the array is not sorted.

The scandir64() function is identical to the scandir() function except that it takes a struct dirent64 instead of a struct dirent. The scandir64() function is a part of the large file extensions.


PARAMETERS

dirname 

Is the name of the directory that scandir() reads.

namelist 

Points to an array of structure pointers.

select 

Points to a routine that is called with a pointer to a directory entry. If the directory entry is to be included in the array, select returns a non-zero value.

compar 

Points to a routine that is passed to qsort() to sort the completed array. If this pointer is NULL, the array is not sorted.


RETURN VALUES

If successful, scandir() or scandir64() returns the number of entries in the array and, through the namelist parameter, returns a pointer to the array. If the directory cannot be opened for reading or if malloc() cannot allocate enough memory to hold all the data structures, scandir() or scandir64() returns -1.


CONFORMANCE

4.4BSD.

scandir64(): Large File Specification, revision 1.5.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
alphasort(), closedir(), malloc(), opendir(), qsort(), readdir()

Miscellaneous:
lf64


PTC MKS Toolkit 10.4 Documentation Build 39.