9 Reprog **exclude, **include;
16 int ni, nmaxi, ne, nmaxe;
19 if(patternfile == nil)
22 f = Bopen(patternfile, OREAD);
24 fatal("cannot open patternfile");
27 include = malloc(nmaxi*sizeof(*include));
29 fatal("out of memory");
33 exclude = malloc(nmaxe*sizeof(*exclude));
35 fatal("out of memory");
37 while(line = Brdline(f, '\n')){
38 line[Blinelen(f) - 1] = 0;
39 if(strlen(line) < 2 || line[1] != ' ')
45 include = realloc(include, nmaxi*sizeof(*include));
47 fatal("out of memory");
49 DEBUG(DFD, "\tinclude %s\n", line+2);
50 include[ni] = regcomp(line+2);
56 exclude = realloc(exclude, nmaxe*sizeof(*exclude));
58 fatal("out of memory");
60 DEBUG(DFD, "\texclude %s\n", line+2);
61 exclude[ne] = regcomp(line+2);
65 DEBUG(DFD, "ignoring pattern %s\n", line);
73 excludefile(char *path)
83 DEBUG(DFD, "checking %s\n", p);
84 for(re = include; *re != nil; re++){
85 if(regexec(*re, p, nil, 0) != 1){
86 DEBUG(DFD, "excluded+ %s\n", p);
90 for(re = exclude; *re != nil; re++){
91 if(regexec(*re, p, nil, 0) == 1){
92 DEBUG(DFD, "excluded- %s\n", p);
100 preaddir(Fid *f, uchar *data, int n, vlong offset)
105 DEBUG(DFD, "\tpreaddir n=%d wo=%lld fo=%lld\n", n, offset, f->offset);
106 if(offset == 0 && f->offset != 0){
107 if(seek(f->fid, 0, 0) != 0)
109 f->offset = f->cdir = f->ndir = 0;
112 }else if(offset != f->offset){
113 werrstr("can't seek dir %lld to %lld", f->offset, offset);
119 f->ndir = dirread(f->fid, &f->dir);
125 d = &f->dir[f->cdir++];
127 char *p = makepath(f->f, d->name);
134 m = convD2M(d, data, n);
135 DEBUG(DFD, "\t\tconvD2M %d\n", m);
137 DEBUG(DFD, "\t\t\tneeded %d\n", GBIT16(data));
138 /* not enough room for full entry; leave for next time */
147 skipentry: if(f->cdir >= f->ndir){
148 f->cdir = f->ndir = 0;