Skip to content

Instantly share code, notes, and snippets.

@kwilczynski
Created April 23, 2012 10:42
Show Gist options
  • Select an option

  • Save kwilczynski/2470160 to your computer and use it in GitHub Desktop.

Select an option

Save kwilczynski/2470160 to your computer and use it in GitHub Desktop.
ftw.h
#include <ftw.h>
#include <stdio.h>
#include <stdlib.h>
int callback(const char *name, const struct stat *status, int type);
int main(int argc, char *argv[])
{
char *root = ".";
ftw((char *) root, callback, 1);
return 0;
}
int callback(const char *name, const struct stat *status, int type)
{
if (type == FTW_NS)
return 0;
if (type == FTW_F || type == FTW_SL || type == FTW_D)
printf("%s\n", name);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment