MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / make_tree_entry

Function make_tree_entry

src/store/store.c:9716–9736  ·  view source on GitHub ↗

Create a file tree entry by checking if a path is a file and counting dir children. */

Source from the content-addressed store, hash-verified

9714
9715/* Create a file tree entry by checking if a path is a file and counting dir children. */
9716static cbm_file_tree_entry_t make_tree_entry(const char *path, char **files, int fn,
9717 char **dir_paths, const int *dir_child_counts,
9718 int dn) {
9719 cbm_file_tree_entry_t e = {0};
9720 e.path = heap_strdup(path);
9721 bool is_file = false;
9722 for (int f = 0; f < fn; f++) {
9723 if (strcmp(files[f], path) == 0) {
9724 is_file = true;
9725 break;
9726 }
9727 }
9728 e.type = heap_strdup(is_file ? "file" : "dir");
9729 for (int d = 0; d < dn; d++) {
9730 if (strcmp(dir_paths[d], path) == 0) {
9731 e.children = dir_child_counts[d];
9732 break;
9733 }
9734 }
9735 return e;
9736}
9737
9738/* Split a path by '/' into parts. Returns number of parts. */
9739static int split_path_parts(const char *fp, char *buf, int buf_sz, char **parts, int max_parts) {

Callers 1

arch_collect_entriesFunction · 0.85

Calls 1

heap_strdupFunction · 0.70

Tested by

no test coverage detected