MCPcopy Index your code
hub / github.com/git/git / dir_iterator_begin

Function dir_iterator_begin

dir-iterator.c:270–305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270struct dir_iterator *dir_iterator_begin(const char *path, unsigned int flags)
271{
272 struct dir_iterator_int *iter = xcalloc(1, sizeof(*iter));
273 struct dir_iterator *dir_iterator = &iter->base;
274 int saved_errno, err;
275
276 strbuf_init(&iter->base.path, PATH_MAX);
277 strbuf_addstr(&iter->base.path, path);
278
279 ALLOC_GROW(iter->levels, 10, iter->levels_alloc);
280 iter->levels_nr = 0;
281 iter->flags = flags;
282
283 /*
284 * Note: lstat already checks for NULL or empty strings and
285 * nonexistent paths.
286 */
287 err = lstat(iter->base.path.buf, &iter->base.st);
288
289 if (err < 0) {
290 saved_errno = errno;
291 goto error_out;
292 }
293
294 if (!S_ISDIR(iter->base.st.st_mode)) {
295 saved_errno = ENOTDIR;
296 goto error_out;
297 }
298
299 return dir_iterator;
300
301error_out:
302 dir_iterator_free(dir_iterator);
303 errno = saved_errno;
304 return NULL;
305}

Callers 4

cmd__dir_iteratorFunction · 0.85
reflog_iterator_beginFunction · 0.85
files_fsck_refs_dirFunction · 0.85
copy_or_link_directoryFunction · 0.85

Calls 4

xcallocFunction · 0.85
strbuf_initFunction · 0.85
strbuf_addstrFunction · 0.85
dir_iterator_freeFunction · 0.85

Tested by 1

cmd__dir_iteratorFunction · 0.68