Files
rk35xx-android14/external/python/cffi/demo/readdir2_build.py
T
hmz007 36ed224bac Rockchip Anroid14_SDK 20240628-rkr5 (2556df1a)
Signed-off-by: hmz007 <hmz007@gmail.com>
Change-Id: Ib87fdbe7a0be7dc961af3500fe9ea4589a127f9f
2024-10-29 18:12:02 +08:00

37 lines
779 B
Python

from cffi import FFI
ffi = FFI()
ffi.cdef("""
typedef ... DIR;
struct dirent {
unsigned char d_type; /* type of file; not supported
by all file system types */
char d_name[...]; /* filename */
...;
};
int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result);
int openat(int dirfd, const char *pathname, int flags);
DIR *fdopendir(int fd);
int closedir(DIR *dirp);
static const int DT_DIR;
""")
ffi.set_source("_readdir2_cffi", """
#ifndef _ATFILE_SOURCE
# define _ATFILE_SOURCE
#endif
#ifndef _BSD_SOURCE
# define _BSD_SOURCE
#endif
#include <fcntl.h>
#include <sys/types.h>
#include <dirent.h>
""")
if __name__ == '__main__':
ffi.compile()