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

Function walk_dir_process_entry

src/discover/discover.c:868–910  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

866}
867
868static void walk_dir_process_entry(cbm_dirent_t *entry, const walk_frame_t *frame,
869 const cbm_discover_opts_t *opts,
870 const cbm_gitignore_t *gitignore,
871 const cbm_gitignore_t *global_gi,
872 const cbm_gitignore_t *cbmignore, walk_stack_t *ws,
873 file_list_t *out) {
874 char abs_path[CBM_SZ_4K];
875 char rel_path[CBM_SZ_4K];
876 int absolute_length = snprintf(abs_path, sizeof(abs_path), "%s/%s", frame->dir, entry->name);
877 int relative_length;
878 if (frame->prefix[0] != '\0') {
879 relative_length = snprintf(rel_path, sizeof(rel_path), "%s/%s", frame->prefix, entry->name);
880 } else {
881 relative_length = snprintf(rel_path, sizeof(rel_path), "%s", entry->name);
882 }
883 if (absolute_length <= 0 || (size_t)absolute_length >= sizeof(abs_path) ||
884 relative_length <= 0 || (size_t)relative_length >= sizeof(rel_path)) {
885 out->failed = true;
886 return;
887 }
888
889 struct stat st;
890 if (safe_stat(abs_path, &st) != 0) {
891 if (out->count_only) {
892 out->failed = true;
893 }
894 return;
895 }
896
897 if (S_ISDIR(st.st_mode)) {
898 if (!dir_is_cache_tree(abs_path) &&
899 !should_skip_directory(entry->name, rel_path, opts, gitignore, global_gi, cbmignore,
900 frame->local_gi, frame->local_gi_prefix)) {
901 walk_push_subdir(ws, abs_path, rel_path, frame, out);
902 } else {
903 /* Record the excluded subtree root so callers can report it (#411). */
904 file_list_add_excluded(out, rel_path);
905 }
906 } else if (S_ISREG(st.st_mode)) {
907 walk_dir_process_file(abs_path, rel_path, entry->name, opts, gitignore, global_gi,
908 cbmignore, frame->local_gi, frame->local_gi_prefix, st.st_size, out);
909 }
910}
911
912static bool walk_owned_gitignore_append(cbm_gitignore_t ***owned, size_t *count, size_t *capacity,
913 cbm_gitignore_t *gitignore) {

Callers 1

walk_dirFunction · 0.85

Calls 6

safe_statFunction · 0.85
dir_is_cache_treeFunction · 0.85
should_skip_directoryFunction · 0.85
walk_push_subdirFunction · 0.85
file_list_add_excludedFunction · 0.85
walk_dir_process_fileFunction · 0.85

Tested by

no test coverage detected