📄 scandir.3
字号:
.\" SCCSID: @(#)scandir.3 8.1 9/11/90.TH scandir 3 .SH Namescandir \- scan a directory.SH Syntax.nf.B #include <sys/types.h>.B #include <sys/dir.h>.PP.B scandir(dirname, namelist, select, compar).B char *dirname;.B struct direct *(*namelist[]);.B int (*select)();.B int (*compar)();.PP.B alphasort(d1, d2).B struct direct **d1, **d2;.fi.SH Description.NXR "scandir subroutine".NXR "directory" "scanning"The.PN scandirsubroutine reads the directory.I dirnameand builds an array of pointers to directoryentries using .MS malloc 3 .It returns the number of entries in the array and a pointer to thearray through.IR namelist ..PPThe.I selectparameter is a pointer to a user supplied subroutine which is called by.PN scandirto select which entries are to be included in the array.The select routine is passed apointer to a directory entry and should return a non-zerovalue if the directory entry is to be included in the array.If.I selectis null, then all the directory entries will be included..PPThe.I comparparameter is a pointer to a user supplied subroutine which is passed to.MS qsort 3to sort the completed array.If this pointer is null, the array is not sorted.The.PN alphasortis a routine which can be used for the.I comparparameter to sort the array alphabetically..PPThe memory allocated for the array can be deallocated with.I freeby freeing each pointer in the array and the array itself.For further information, see .MS malloc 3 ..SH DiagnosticsReturns \-1 if the directory cannot be opened for reading or if.MS malloc 3cannot allocate enough memory to hold all the data structures..SH See Alsodirectory(3), malloc(3), qsort(3), dir(5)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -