Skip to content

Instantly share code, notes, and snippets.

@Ambrevar
Ambrevar / walk.c
Last active October 26, 2015 15:34
Fast tree walk
/* Traverse a folder recursively, save all regular files to a slice and print
the final slice.
The slice structure is heavily inspired from Go. The main differences are: 1) its
memory needs to be freed, 2) the len() and cap() functions retun a size_t, not
an int.
The walk is optimized by using the `d_type` field from the `dirent` structure.
It works on *BSD and Linux but might not work on other systems.
*/