Обеспечить контроль над открытой директорией
#include <dirent.h>int dircntl( DIR *dir,int cmd,... );
<dirent.h>
определены как минимум следующие значения: libc
Функция dircntl() обеспечивает контроль для открытой директории, на которую ссылается аругмент dir. Эта функция ведет себя аналогично функции управления файлами fcntl().
Флаги:
D_GETFLAG
-1
, код ошибки записывается в errno. D_SETFLAG
0
. Если возникла ошибка, функция возвращает -1
, код ошибки записывается в errno. #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);}
ЗОСРВ «Нейтрино»
struct stat, fcntl(), opendir(), readdir()
Предыдущий раздел: Описание API системной библиотеки