dircntl()

Control an open directory

Synopsis:

#include <dirent.h>

int dircntl( DIR * dir,
             int cmd,
             ... );

Since:

BlackBerry 10.0.0

Arguments:

dir
Provide control for this directory.
cmd
At least the following values are defined in <dirent.h>:
  • D_GETFLAG — retrieve the flags associated with the directory referenced by dir. For more information, see " Flag values," below.
  • D_SETFLAG — set the flags associated with the directory referenced by dir to the value given as an additional argument. The new value can be any combination of the flags described in " Flag values," below.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

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().

Flag values

D_FLAG_FILTER
Filter out duplicate name entries that may occur due to the union filesystem during a readdir() operation.
D_FLAG_STAT
Indicate to servers that they should attempt to return extra stat() information as part of the readdir() operation.

Returns:

The return value depends on the value of cmd:

D_GETFLAG
The flags associated with the directory.
D_SETFLAG
0.
Any other value
-1 ( errno is set to ENOSYS).

Examples:

#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;
}

Classification:

QNX Neutrino

Safety:  
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes

Last modified: 2014-06-24



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus