2014-12-02 07:34:06 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fts.h>
|
|
|
|
#include <stdio.h>
|
2017-01-21 13:01:39 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#ifdef FTS_COMPARE_CONST
|
|
|
|
int fts_compare(const FTSENT *const *, const FTSENT *const *);
|
|
|
|
#else
|
|
|
|
int fts_compare(const FTSENT **, const FTSENT **);
|
|
|
|
#endif
|
2014-12-02 07:34:06 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
|
|
|
const char *argv[2];
|
|
|
|
FTS *ftsp;
|
|
|
|
FTSENT *entry;
|
|
|
|
|
|
|
|
argv[0] = ".";
|
|
|
|
argv[1] = (char *)NULL;
|
|
|
|
|
|
|
|
ftsp = fts_open((char * const *)argv,
|
2017-01-21 13:01:39 +00:00
|
|
|
FTS_PHYSICAL | FTS_NOCHDIR, fts_compare);
|
2014-12-02 07:34:06 +00:00
|
|
|
|
|
|
|
if (ftsp == NULL) {
|
|
|
|
perror("fts_open");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2014-12-02 07:34:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
entry = fts_read(ftsp);
|
|
|
|
|
|
|
|
if (entry == NULL) {
|
|
|
|
perror("fts_read");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2014-12-02 07:34:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fts_set(ftsp, entry, FTS_SKIP) != 0) {
|
|
|
|
perror("fts_set");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2014-12-02 07:34:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fts_close(ftsp) != 0) {
|
|
|
|
perror("fts_close");
|
2016-01-15 23:08:59 +00:00
|
|
|
return 1;
|
2014-12-02 07:34:06 +00:00
|
|
|
}
|
|
|
|
|
2016-01-15 23:08:59 +00:00
|
|
|
return 0;
|
2014-12-02 07:34:06 +00:00
|
|
|
}
|
2017-01-21 13:01:39 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
#ifdef FTS_COMPARE_CONST
|
|
|
|
fts_compare(const FTSENT *const *a, const FTSENT *const *b)
|
|
|
|
#else
|
|
|
|
fts_compare(const FTSENT **a, const FTSENT **b)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
return strcmp((*a)->fts_name, (*b)->fts_name);
|
|
|
|
}
|