mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-30 03:47:05 -05: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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue