Lines Matching +full:dir +full:- +full:glob
2 #include <glob.h>
23 if (!new) return -1; in append()
24 (*tail)->next = new; in append()
25 new->next = NULL; in append()
26 memcpy(new->name, name, len+1); in append()
27 if (mark && len && name[len-1]!='/') { in append()
28 new->name[len] = '/'; in append()
29 new->name[len+1] = 0; in append()
40 /* Special-case the remaining pattern being all slashes, in in do_glob()
41 * which case we can use caller-passed type if it's a dir. */ in do_glob()
45 /* Consume maximal [escaped-]literal prefix of pattern, copying in do_glob()
46 * and un-escaping it to the running buffer as we go. */ in do_glob()
60 * our interpretation) non-special, so if next in do_glob()
71 i = -1; in do_glob()
73 j = -1; in do_glob()
87 /* If we consume any new components, the caller-passed type in do_glob()
94 * requested and we don't yet know if the match is a dir, in do_glob()
121 for (p=p2; p>pat && p[-1]=='\\'; p--); in do_glob()
122 if ((p2-p)%2) { in do_glob()
123 p2--; in do_glob()
127 DIR *dir = opendir(pos ? buf : "."); in do_glob() local
128 if (!dir) { in do_glob()
135 while (errno=0, de=readdir(dir)) { in do_glob()
136 /* Quickly skip non-directories when there's pattern left. */ in do_glob()
137 if (p2 && de->d_type && de->d_type!=DT_DIR && de->d_type!=DT_LNK) in do_glob()
140 size_t l = strlen(de->d_name); in do_glob()
141 if (l >= PATH_MAX-pos) continue; in do_glob()
148 if (fnmatch(pat, de->d_name, fnm_flags)) in do_glob()
153 if (p2 && (flags & GLOB_PERIOD) && de->d_name[0]=='.' in do_glob()
154 && (!de->d_name[1] || de->d_name[1]=='.' && !de->d_name[2]) in do_glob()
155 && fnmatch(pat, de->d_name, fnm_flags | FNM_PERIOD)) in do_glob()
158 memcpy(buf+pos, de->d_name, l+1); in do_glob()
160 int r = do_glob(buf, pos+l, de->d_type, p2 ? p2 : "", flags, errfunc, tail); in do_glob()
162 closedir(dir); in do_glob()
168 closedir(dir); in do_glob()
183 for (match=head->next; match; match=next) { in freelist()
184 next = match->next; in freelist()
217 while (i < PATH_MAX - 2 && *home) in expand_tilde()
227 int glob(const char *restrict pat, int flags, int (*errfunc)(const char *path, int err), glob_t *re… in glob() function
231 size_t offs = (flags & GLOB_DOOFFS) ? g->gl_offs : 0; in glob()
238 g->gl_offs = offs; in glob()
239 g->gl_pathc = 0; in glob()
240 g->gl_pathv = NULL; in glob()
261 for (cnt=0, tail=head.next; tail; tail=tail->next, cnt++); in glob()
273 char **pathv = realloc(g->gl_pathv, (offs + g->gl_pathc + cnt + 1) * sizeof(char *)); in glob()
278 g->gl_pathv = pathv; in glob()
279 offs += g->gl_pathc; in glob()
281 g->gl_pathv = malloc((offs + cnt + 1) * sizeof(char *)); in glob()
282 if (!g->gl_pathv) { in glob()
287 g->gl_pathv[i] = NULL; in glob()
289 for (i=0, tail=head.next; i<cnt; tail=tail->next, i++) in glob()
290 g->gl_pathv[offs + i] = tail->name; in glob()
291 g->gl_pathv[offs + i] = NULL; in glob()
292 g->gl_pathc += cnt; in glob()
295 qsort(g->gl_pathv+offs, cnt, sizeof(char *), sort); in glob()
303 for (i=0; i<g->gl_pathc; i++) in globfree()
304 free(g->gl_pathv[g->gl_offs + i] - offsetof(struct match, name)); in globfree()
305 free(g->gl_pathv); in globfree()
306 g->gl_pathc = 0; in globfree()
307 g->gl_pathv = NULL; in globfree()
310 weak_alias(glob, glob64);