Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions libdftw.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ enum {
#define FTW_NS FTW_NS
};

#define DFTW_CONTINUE 0
#define DFTW_SKIP_SUBTREE 1

/*
* Callbacks should return DFTW_CONTINUE to continue traversal. Returning
* DFTW_SKIP_SUBTREE from an FTW_D callback skips descending into that
* directory while allowing the walk to continue elsewhere.
*/
void dftw(const char *dirpath,
int (*fn) (const char *fpath, const struct stat *sb, int typeflag));

Expand Down
9 changes: 6 additions & 3 deletions libdftw/dftw.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <stdlib.h>
#include <libcircle.h>

#include <dirent.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -36,6 +36,7 @@ void DFTW_create(CIRCLE_handle* handle)
void DFTW_process(CIRCLE_handle* handle)
{
struct stat st;
int cb_rc = DFTW_CONTINUE;
int status = 0;

char temp[CIRCLE_MAX_STRING_LEN];
Expand All @@ -51,8 +52,10 @@ void DFTW_process(CIRCLE_handle* handle)
}

else if(S_ISDIR(st.st_mode) && !(S_ISLNK(st.st_mode))) {
_DFTW_CB(temp, &st, FTW_D);
DFTW_process_dir(temp, handle);
cb_rc = _DFTW_CB(temp, &st, FTW_D);
if(cb_rc == DFTW_CONTINUE) {
DFTW_process_dir(temp, handle);
}
}
else if(S_ISREG(st.st_mode)) {
_DFTW_CB(temp, &st, FTW_F);
Expand Down