nifd->namenode->divert && nifd->namenode->divert->useinstead
? nifd->namenode->divert->useinstead->name : "<none>");
- if (filters) {
- int remove = 0;
- struct filterlist *f;
-
- /* Last match wins */
- for (f = filters; f != NULL; f = f->next) {
- debug(dbg_eachfile, "tarobject comparing '%s' and '%s'", &ti->Name[1], f->filterstring);
- if (fnmatch(f->filterstring, &ti->Name[1], 0) == 0) {
- if (f->positive == 0) {
- remove = 1;
- debug(dbg_eachfile, "tarobject removing %s", ti->Name);
- } else {
- remove = 0;
- debug(dbg_eachfile, "tarobject including %s", ti->Name);
-
- }
- }
- }
-
- if (remove) {
- for (f = filters; f != NULL; f = f->next) {
- char *pattern;
-
- pattern = malloc(strlen(ti->Name) + 1);
- strcpy(pattern, &ti->Name[1]);
- strcat(pattern, "*");
-
- debug(dbg_eachfile, "tarobject seeing if '%s' needs to be reincluded", &ti->Name[1]);
- if ((f->positive == 1) &&
- (ti->Type == Directory) &&
- (fnmatch(pattern, f->filterstring, 0) == 0)) {
- remove = 0;
- debug(dbg_eachfile, "tarobject reincluding %s", ti->Name);
- }
- }
- }
-
- if (remove) {
+ if (filter_should_skip(ti) == 1) {
struct filenamenode *fnn = findnamenode(ti->Name, 0);
fnn->flags &= ~fnnf_new_inarchive;
obstack_free(&tar_obs, nifd);
if (r > 0) r= safe_read(tc->backendpipe,databuf,TARBLKSZ - r);
}
return 0;
- }
}
if (nifd->namenode->divert && nifd->namenode->divert->camefrom) {
#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>
+#include <fnmatch.h>
#include <dpkg.h>
#include "filters.h"
+#include "main.h"
struct filterlist *filters = NULL;
}
closedir(dir);
}
+
+int filter_should_skip(struct TarInfo *ti) {
+ int remove = 0;
+ if (filters) {
+ struct filterlist *f;
+
+ /* Last match wins */
+ for (f = filters; f != NULL; f = f->next) {
+ debug(dbg_eachfile, "tarobject comparing '%s' and '%s'", &ti->Name[1], f->filterstring);
+ if (fnmatch(f->filterstring, &ti->Name[1], 0) == 0) {
+ if (f->positive == 0) {
+ remove = 1;
+ debug(dbg_eachfile, "do_filter removing %s", ti->Name);
+ } else {
+ remove = 0;
+ debug(dbg_eachfile, "do_filter including %s", ti->Name);
+ }
+ }
+ }
+
+ if (remove) {
+ for (f = filters; f != NULL; f = f->next) {
+ char *pattern;
+
+ pattern = malloc(strlen(ti->Name) + 1);
+ strcpy(pattern, &ti->Name[1]);
+ strcat(pattern, "*");
+
+ debug(dbg_eachfile,
+ "tarobject seeing if '%s' needs to be reincluded", &ti->Name[1]);
+ if ((f->positive == 1) &&
+ (ti->Type == Directory) &&
+ (fnmatch(pattern, f->filterstring, 0) == 0)) {
+ remove = 0;
+ debug(dbg_eachfile, "tarobject reincluding %s", ti->Name);
+ }
+ }
+ }
+ }
+ return remove;
+}