• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1from cffi import FFI
2
3ffi = FFI()
4ffi.cdef("""
5
6    typedef ... DIR;
7
8    struct dirent {
9        unsigned char  d_type;      /* type of file; not supported
10                                       by all file system types */
11        char           d_name[...]; /* filename */
12        ...;
13    };
14
15    int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
16    int openat(int dirfd, const char *pathname, int flags);
17    DIR *fdopendir(int fd);
18    int closedir(DIR *dirp);
19
20    static const int DT_DIR;
21
22""")
23ffi.set_source("_readdir2_cffi", """
24#ifndef _ATFILE_SOURCE
25#  define _ATFILE_SOURCE
26#endif
27#ifndef _BSD_SOURCE
28#  define _BSD_SOURCE
29#endif
30#include <fcntl.h>
31#include <sys/types.h>
32#include <dirent.h>
33""")
34
35if __name__ == '__main__':
36    ffi.compile()
37