MCPcopy Create free account
hub / github.com/git/git / count_dir_entries

Function count_dir_entries

t/unit-tests/u-reftable-stack.c:30–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30static int count_dir_entries(const char *dirname)
31{
32 DIR *dir = opendir(dirname);
33 int len = 0;
34 struct dirent *d;
35 if (!dir)
36 return 0;
37
38 while ((d = readdir(dir))) {
39 /*
40 * Besides skipping over "." and "..", we also need to
41 * skip over other files that have a leading ".". This
42 * is due to behaviour of NFS, which will rename files
43 * to ".nfs*" to emulate delete-on-last-close.
44 *
45 * In any case this should be fine as the reftable
46 * library will never write files with leading dots
47 * anyway.
48 */
49 if (starts_with(d->d_name, "."))
50 continue;
51 len++;
52 }
53 closedir(dir);
54 return len;
55}
56
57/*
58 * Work linenumber into the tempdir, so we can see which tests forget to

Calls 4

opendirFunction · 0.85
readdirFunction · 0.85
starts_withFunction · 0.85
closedirFunction · 0.85