Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
scandir(3)
Edit
PageHistory
Diff
Info
LikePages
SCANDIR !!!SCANDIR NAME SYNOPSIS DESCRIPTION RETURN VALUE ERRORS CONFORMING TO EXAMPLE SEE ALSO ---- !!NAME scandir, alphasort, versionsort - scan a directory for matching entries !!SYNOPSIS __#include __''dir''__, struct dirent ***__''namelist''__, int (*__''select''__)(const struct dirent *), int (*__''compar''__)(const void *, const void *)); int alphasort(const void *__''a''__, const void *__''b''__); int versionsort(const void *__''a''__, const void *__''b''__); __ !!DESCRIPTION The __scandir()__ function scans the directory ''dir'', calling __select()__ on each directory entry. Entries for which __select()__ returns non-zero are stored in strings allocated via __malloc()__, sorted using __qsort()__ with the comparison function __compar()__, and collected in array ''namelist'' which is allocated via __malloc()__. The __alphasort()__ and __versionsort()__ functions can be used as the comparison function for the __scandir()__ function to sort the directory entries into alphabetical order. Although they parameters point to void, they are in fact pointers to pointers (__struct dirent**__) to two directory entries, ''a'' and ''b'', to compare. __alphasort()__ will order the files with strcoll(3), while __versionsort()__ will use strverscmp(3). !!RETURN VALUE The __scandir()__ function returns the number of directory entries selected or -1 if an error occurs. The __alphasort()__ and __versionsort()__ functions return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. !!ERRORS __ENOMEM__ Insufficient memory to complete the operation. !!CONFORMING TO BSD 4.3 !!EXAMPLE /* print files in current directory in reverse order */ #include !!SEE ALSO opendir(3), readdir(3), closedir(3), rewinddir(3), telldir(3), seekdir(3) ----
7 pages link to
scandir(3)
:
Man3s
closedir(3)
opendir(3)
readdir(3)
rewinddir(3)
seekdir(3)
telldir(3)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.