← board

Directory scanning support — sys_getdents64 (libc-free)

Goal

Provide a statically-linked, libc-free directory scanning mechanism in the RTL using raw Linux system calls (sys_getdents64).

Surface (sketch)

In lib/rtl/platform.pas (or per-platform files):

In lib/rtl/sysutils.pas:

Implementation Steps

  1. Expose sys_getdents64 in lib/rtl/platform.pas for the different target architectures (x86_64, i386, aarch64, arm32).
  2. Open directory file descriptor using sys_open with O_RDONLY | O_DIRECTORY.
  3. Loop over sys_getdents64 with a local buffer (e.g. 4096 bytes) and decode the variable-length linux_dirent64 structures using pointer offsets.
  4. Filter out . and .. directory links.
  5. Close the descriptor and return the parsed TFileInfo records.

Log