mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Change the rule output format to match the input one
This commit is contained in:
parent
83e1629868
commit
5665336c16
4 changed files with 23 additions and 34 deletions
|
|
@ -125,30 +125,22 @@ void filter_free(struct snapraid_filter* filter)
|
|||
free(filter);
|
||||
}
|
||||
|
||||
const char* filter_type(struct snapraid_filter* filter)
|
||||
const char* filter_type(struct snapraid_filter* filter, char* out, size_t out_size)
|
||||
{
|
||||
if (filter->direction < 0) {
|
||||
if (filter->is_disk)
|
||||
return "exclude (disk)";
|
||||
if (filter->is_path)
|
||||
return "exclude (path)";
|
||||
if (filter->is_dir)
|
||||
return "exclude (dir)";
|
||||
return "exclude (file)";
|
||||
} else {
|
||||
if (filter->is_disk)
|
||||
return "include (disk)";
|
||||
if (filter->is_path)
|
||||
return "include (path)";
|
||||
if (filter->is_dir)
|
||||
return "include (dir)";
|
||||
return "include (file)";
|
||||
}
|
||||
}
|
||||
const char* direction;
|
||||
if (filter->direction < 0)
|
||||
direction = "exclude";
|
||||
else
|
||||
direction = "include";
|
||||
|
||||
const char* filter_pattern(struct snapraid_filter* filter)
|
||||
{
|
||||
return filter->pattern;
|
||||
if (filter->is_disk)
|
||||
pathprint(out, out_size, "%s %s:", direction, filter->pattern);
|
||||
else if (filter->is_dir)
|
||||
pathprint(out, out_size, "%s %s/", direction, filter->pattern);
|
||||
else
|
||||
pathprint(out, out_size, "%s %s", direction, filter->pattern);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
static int filter_apply(struct snapraid_filter* filter, struct snapraid_filter** reason, const char* path, const char* name, int is_dir)
|
||||
|
|
|
|||
|
|
@ -429,12 +429,7 @@ void filter_free(struct snapraid_filter* filter);
|
|||
/**
|
||||
* Filter type description.
|
||||
*/
|
||||
const char* filter_type(struct snapraid_filter* filter);
|
||||
|
||||
/**
|
||||
* Filter patter description.
|
||||
*/
|
||||
const char* filter_pattern(struct snapraid_filter* filter);
|
||||
const char* filter_type(struct snapraid_filter* filter, char* out, size_t out_size);
|
||||
|
||||
/**
|
||||
* Filter hidden files.
|
||||
|
|
|
|||
|
|
@ -1180,6 +1180,7 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
|
|||
while (node != 0) {
|
||||
char path_next[PATH_MAX];
|
||||
char sub_next[PATH_MAX];
|
||||
char out[PATH_MAX];
|
||||
struct snapraid_filter* reason = 0;
|
||||
struct dirent_sorted* dd = node->data;
|
||||
const char* name = dd->d_name;
|
||||
|
|
@ -1262,7 +1263,7 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
|
|||
processed = 1;
|
||||
} else {
|
||||
if (state->opt.verbose) {
|
||||
printf("Excluding file '%s' for rule '%s %s'\n", path_next, filter_type(reason), filter_pattern(reason));
|
||||
printf("Excluding file '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out)));
|
||||
}
|
||||
}
|
||||
} else if (type == 1) { /* LNK */
|
||||
|
|
@ -1292,7 +1293,7 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
|
|||
processed = 1;
|
||||
} else {
|
||||
if (state->opt.verbose) {
|
||||
printf("Excluding link '%s' for rule '%s %s'\n", path_next, filter_type(reason), filter_pattern(reason));
|
||||
printf("Excluding link '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out)));
|
||||
}
|
||||
}
|
||||
} else if (type == 2) { /* DIR */
|
||||
|
|
@ -1324,7 +1325,7 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
|
|||
}
|
||||
} else {
|
||||
if (state->opt.verbose) {
|
||||
printf("Excluding directory '%s' for rule '%s %s'\n", path_next, filter_type(reason), filter_pattern(reason));
|
||||
printf("Excluding directory '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1336,7 +1337,7 @@ static int scan_dir(struct snapraid_scan* scan, int is_diff, const char* dir, co
|
|||
fprintf(stderr, "WARNING! Ignoring special '%s' file '%s'\n", stat_desc(st), path_next);
|
||||
} else {
|
||||
if (state->opt.verbose) {
|
||||
printf("Excluding special file '%s' for rule '%s %s'\n", path_next, filter_type(reason), filter_pattern(reason));
|
||||
printf("Excluding special file '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
|
|||
while (1) {
|
||||
char path_next[PATH_MAX];
|
||||
char sub_next[PATH_MAX];
|
||||
char out[PATH_MAX];
|
||||
struct snapraid_filter* reason = 0;
|
||||
struct stat st;
|
||||
const char* name;
|
||||
|
|
@ -239,7 +240,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
|
|||
search_file(state, path_next, st.st_size, st.st_mtime, STAT_NSEC(&st));
|
||||
} else {
|
||||
if (state->opt.verbose) {
|
||||
printf("Excluding link '%s' for rule '%s %s'\n", path_next, filter_type(reason), filter_pattern(reason));
|
||||
printf("Excluding link '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out)));
|
||||
}
|
||||
}
|
||||
} else if (S_ISDIR(st.st_mode)) {
|
||||
|
|
@ -249,7 +250,7 @@ static void search_dir(struct snapraid_state* state, struct snapraid_disk* disk,
|
|||
search_dir(state, disk, path_next, sub_next);
|
||||
} else {
|
||||
if (state->opt.verbose) {
|
||||
printf("Excluding directory '%s' for rule '%s %s'\n", path_next, filter_type(reason), filter_pattern(reason));
|
||||
printf("Excluding directory '%s' for rule '%s'\n", path_next, filter_type(reason, out, sizeof(out)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue