Control an open directory
#include <dirent.h> int dircntl( DIR * dir, int cmd, ... );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The dircntl() function provides control over the open directory referenced by the dir argument. This function behaves in a manner similar to the file control function, fcntl().
The return value depends on the value of cmd:
#include <stdio.h> #include <stdlib.h> #include <dirent.h> int main(int argc, char **argv) { DIR *dp; int ret; if(!(dp = opendir("/"))) { exit(EXIT_FAILURE); } /* Display the flags that are set on the directory by default*/ if((ret = dircntl(dp, D_GETFLAG)) == -1) { exit(EXIT_FAILURE); } if(ret & D_FLAG_FILTER) { printf("Directory names are filtered\n"); } else { printf("Directory names are not filtered\n"); } if(ret & D_FLAG_STAT) { printf("Servers asked for extra stat information\n"); } else { printf("Servers not asked for extra stat information\n"); } closedir(dp); return 0; }
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |