MCPcopy Create free account
hub / github.com/ElementsProject/lightning / get_files

Function get_files

tools/check-bolt.c:43–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43static bool get_files(const char *dir, const char *subdir,
44 struct bolt_file **files)
45{
46 char *path = path_join(NULL, dir, subdir);
47 DIR *d = opendir(path);
48 struct dirent *e;
49
50 if (!d)
51 return false;
52
53 while ((e = readdir(d)) != NULL) {
54 int preflen;
55 struct bolt_file bf;
56
57 /* Must end in .md */
58 if (!strends(e->d_name, ".md"))
59 continue;
60
61 /* Prefix is anything up to - */
62 preflen = strspn(e->d_name,
63 "0123456789"
64 "abcdefghijklmnopqrstuvwxyz"
65 "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
66 if (!preflen)
67 continue;
68 if (preflen + strlen(".md") != strlen(e->d_name)
69 && e->d_name[preflen] != '-')
70 continue;
71
72 if (verbose)
73 printf("Found bolt %.*s\n", preflen, e->d_name);
74
75 bf.prefix = tal_strndup(*files, e->d_name, preflen);
76 bf.contents
77 = canonicalize(grab_file(*files,
78 path_join(path, path,
79 e->d_name)));
80 tal_arr_expand(files, bf);
81 }
82 return true;
83}
84
85static struct bolt_file *get_bolt_files(const char *dir)
86{

Callers 1

get_bolt_filesFunction · 0.85

Calls 4

path_joinFunction · 0.85
strendsFunction · 0.85
canonicalizeFunction · 0.85
grab_fileFunction · 0.85

Tested by

no test coverage detected