mkdir(), rmdir(), and readdir() are POSIX primitives that every shell's `ls`, `mkdir -p`, and file manager ultimately call, and the . and .. entries you handle here are why `cd ..` works on every Unix system. Forgetting to skip . and .. when counting files is a classic bug that silently inflates file counts in backup and sync tools.