ANGRYsearch icon indicating copy to clipboard operation
ANGRYsearch copied to clipboard

Fix FreeBSD 12+ support

Open danfe opened this issue 4 years ago • 0 comments

In recent FreeBSD versions struct dirent was changed as part of the 64-bit inode project. Consider the following patch which allows scandir.py to support both new (12+) and old (<12) layout.

--- scandir.py.orig
+++ scandir.py
@@ -428,6 +428,17 @@ elif sys.platform.startswith(('linux', 'darwin')) or '
                 ('d_type', ctypes.c_byte),
                 ('d_name', ctypes.c_char * 256),
             )
+        elif sys.platform.startswith('freebsd') and int(sys.platform[7:]) > 11:
+            _fields_ = (
+                ('d_ino', ctypes.c_uint64),
+                ('d_off', ctypes.c_uint64),
+                ('d_reclen', ctypes.c_ushort),
+                ('d_type', ctypes.c_byte),
+                ('d_pad0', ctypes.c_byte),
+                ('d_namlen', ctypes.c_ushort),
+                ('d_pad1', ctypes.c_ushort),
+                ('d_name', ctypes.c_char * 256),
+            )
         else:
             _fields_ = (
                 ('d_ino', ctypes.c_uint32),  # must be uint32, not ulong

danfe avatar Jun 09 '20 14:06 danfe