I am reading the content of the current library with readdir, but I would like to treat only files and not directories. How do I know that I am pointing to a directory and not to a file?
I am reading the content of the current library with readdir , but I
Share
You can use lstat, and the S_ISDIR macro.
E.g. without error-checking:
EDIT: Fixed to include directory in lstat path (per el.pescado). As noted by R Samuel Klatchko, you may want to take a whitelist approach (S_ISREG) instead of blacklisting types as they come up.