Ubuntu listing up files recursively, detecting sym-links

view story

http://stackoverflow.com – I'm trying to list up my local file-system recursively using dirent.h. In order to prevent from following sym-links, I'm using the sys/stat.h header. In the following you can find my SSCCE program. /** * coding: utf-8 * * Copyright (C) 2013, Niklas Rosenstein * * listdir.c - List up directories and file-content recursively. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <dirent.h> #include <sys/stat.h> void list_dir(const char* directory_name) { DIR* directory_handle = opendir(directory_name); if (directory_handle == NULL) (HowTos)