Adds include logic in filtering.

This commit is contained in:
Andrea Mazzoleni 2011-04-26 18:51:42 +02:00
parent 99420cffab
commit cb4a72afca
11 changed files with 248 additions and 92 deletions

20
scan.c
View file

@ -186,22 +186,6 @@ static void scan_file(struct snapraid_scan* scan, struct snapraid_state* state,
scan_file_insert(state, disk, file);
}
/**
* Checks if the specified path/file should be listet.
*/
static int scan_filter(struct snapraid_state* state, const char* path, const char* file, int is_dir)
{
tommy_node* node = tommy_list_head(&state->excludelist);
while (node) {
struct snapraid_filter* filter = node->data;
if (filter_path(filter, path, file, is_dir) == 0)
return -1;
node = node->next;
}
return 0;
}
/**
* Processes a directory.
*/
@ -241,7 +225,7 @@ static void scan_dir(struct snapraid_scan* scan, struct snapraid_state* state, s
}
if (S_ISREG(st.st_mode)) {
if (scan_filter(state, sub_next, name, 0) == 0) {
if (filter_path(&state->filterlist, sub_next, 0) == 0) {
scan_file(scan, state, disk, sub_next, &st);
} else {
if (state->verbose) {
@ -249,7 +233,7 @@ static void scan_dir(struct snapraid_scan* scan, struct snapraid_state* state, s
}
}
} else if (S_ISDIR(st.st_mode)) {
if (scan_filter(state, sub_next, name, 1) == 0) {
if (filter_path(&state->filterlist, sub_next, 1) == 0) {
pathslash(path_next, sizeof(path_next));
pathslash(sub_next, sizeof(sub_next));
scan_dir(scan, state, disk, path_next, sub_next);