mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 10:51:54 -04:00
Completes filtering with patterns.
This commit is contained in:
parent
a70eb4ed2b
commit
bd80df19ac
3 changed files with 37 additions and 8 deletions
32
elem.c
32
elem.c
|
|
@ -100,8 +100,36 @@ int filter_path(struct snapraid_filter* filter, const char* path, const char* na
|
|||
|
||||
int filter_file(struct snapraid_filter* filter, struct snapraid_file* file)
|
||||
{
|
||||
/* only partially correct as we are not filtering dirs */
|
||||
return filter_path(filter, file->sub, file_name(file), 0);
|
||||
char path[PATH_MAX];
|
||||
char* name;
|
||||
unsigned i;
|
||||
|
||||
pathcpy(path, sizeof(path), file->sub);
|
||||
|
||||
/* filter for all the directory */
|
||||
name = path;
|
||||
for(i=0;path[i] != 0;++i) {
|
||||
if (path[i] == '/') {
|
||||
/* set a terminator */
|
||||
path[i] = 0;
|
||||
|
||||
/* filter the directory */
|
||||
if (filter_path(filter, path, name, 1) == 0)
|
||||
return 0;
|
||||
|
||||
/* restore the slash */
|
||||
path[i] = '/';
|
||||
|
||||
/* next name */
|
||||
name = path + i + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* filter the final file */
|
||||
if (filter_path(filter, path, name, 0) == 0)
|
||||
return 0;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
block_off_t block_file_pos(struct snapraid_block* block)
|
||||
|
|
|
|||
4
scan.c
4
scan.c
|
|
@ -240,7 +240,7 @@ static void scan_dir(struct snapraid_scan* scan, struct snapraid_state* state, s
|
|||
scan_file(scan, state, disk, sub_next, &st);
|
||||
} else {
|
||||
if (state->verbose) {
|
||||
printf("warning: Excluded file '/%s'\n", sub_next);
|
||||
printf("Excluding file '/%s'\n", sub_next);
|
||||
}
|
||||
}
|
||||
} else if (S_ISDIR(st.st_mode)) {
|
||||
|
|
@ -250,7 +250,7 @@ static void scan_dir(struct snapraid_scan* scan, struct snapraid_state* state, s
|
|||
scan_dir(scan, state, disk, path_next, sub_next);
|
||||
} else {
|
||||
if (state->verbose) {
|
||||
printf("warning: Excluded directory '/%s'\n", sub_next);
|
||||
printf("Excluding directory '/%s'\n", sub_next);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
9
state.c
9
state.c
|
|
@ -523,10 +523,7 @@ void state_filter(struct snapraid_state* state, tommy_list* filterlist)
|
|||
tommy_node* k;
|
||||
for(k=tommy_list_head(filterlist);k!=0;k=k->next) {
|
||||
struct snapraid_filter* filter = k->data;
|
||||
printf("\t");
|
||||
if (filter->is_path)
|
||||
printf("/");
|
||||
printf("%s", filter->pattern);
|
||||
printf("\t%s", filter->pattern);
|
||||
if (filter->is_dir)
|
||||
printf("/");
|
||||
printf("\n");
|
||||
|
|
@ -556,6 +553,10 @@ void state_filter(struct snapraid_state* state, tommy_list* filterlist)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (state->verbose && !file->is_filtered) {
|
||||
printf("Processing file '%s'\n", file->sub);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue