2 # Exit 0 if "." has useful d_type information, else 1.
3 # Intended to exit 0 only on Linux/GNU systems.
10 (DT_UNKNOWN, DT_DIR,) = (0, 4,)
12 class dirent(ctypes.Structure):
14 ("d_ino", ctypes.c_long),
15 ("d_off", ctypes.c_long),
16 ("d_reclen", ctypes.c_ushort),
17 ("d_type", ctypes.c_ubyte),
18 ("d_name", ctypes.c_char*256)]
20 direntp = ctypes.POINTER(dirent)
22 # FIXME: find a way to hard-coding libc's so-name.
23 libc = ctypes.cdll.LoadLibrary("libc.so.6")
24 libc.readdir.restype = direntp
26 dirp = libc.opendir(".")
28 ep = libc.readdir(dirp)
30 name = ep.contents.d_name
31 if (name == "." or name == "..") and ep.contents.d_type == DT_DIR: