code wiki / (root) / nx_find.nx

nx_find.nx

buildroot/runtime/nx_find.nx

6549 B220 linesdepth 6pulls 9 transitivereach 1 importersview sourcekind librarytopic find
docsdependenciesstructsconstsfunctions

about

nx_find.nx -- S5 stone of NISHI_SHELL_REPLACEMENT_ROADMAP.md. Canonical: this is the substrate-wide canonical file-tree walk + filter primitive per [[feedback-bits-up-shell-replace-linux- brother-tools]]. Composes nx_dir + nx_string_ops + nx_grep. Replaces the bash `find` / `ls | xargs grep` patterns scattered across substrate audit scripts. S6 will add recursive walks + gitignore-aware exclusions (fd 2017 style); this S5 first stone ships the per-level filter primitives that the recursive walker composes. API (all pure-function over caller-provided NxDirRow arrays; no syscalls in the LOGIC layer; caller composes nx_dir_list to populate rows then runs filters): nx_find_filter_suffix(rows, n_rows, suffix, n_suffix, out_flags) -> i64 For each row, sets out_flags[i] = 1 iff name ends with suffix. Returns count of kept rows. nx_find_filter_prefix(rows, n_rows, prefix, n_prefix, out_flags) -> i64 For each row, sets out_flags[i] = 1 iff name starts with prefix. Returns count of kept rows. nx_find_filter_regular_files(rows, n_rows, out_flags) -> i64 For each row, sets out_flags[i] = 1 iff dtype == NX_DT_REG. Returns count of kept rows. nx_find_filter_skip_dotlike(rows, n_rows, out_flags) -> i64 For each row, sets out_flags[i] = 1 iff NOT is_dotlike. nx_find_intersect(a, b, n, out_flags) -> i64 out_flags[i] = a[i] AND b[i]. Composes multiple filters. nx_find_count_kept(flags, n) -> i64 Sum of 1s in flags array. nx_find_nth_kept_index(flags, n, k) -> i64 Returns the index of the k-th kept row (0-based), or -1 if k exceeds count. Lets the caller iterate kept rows without allocating a separate index list.

dependencies 3 imports · 1 importers

nx_syscalls.nx nx_string_ops.nx nx_dir.nx nx_find.nx nx_find_test.nx

imports: nx_syscalls.nxnx_string_ops.nxnx_dir.nx

imported by: nx_find_test.nx

structs

none

consts

none

functions

75func nx_find_filter_suffix(
called by 1: main calls 2: nx_dir_row_atnx_str_ends_with
100func nx_find_filter_prefix(
125func nx_find_filter_regular_files(
called by 1: main calls 1: nx_dir_row_at
146func nx_find_filter_skip_dotlike(
called by 1: main calls 1: nx_dir_row_at
170func nx_find_intersect(
called by 1: main
196func nx_find_count_kept(flags: *i64, n: i64) -> i64
called by 1: main
208func nx_find_nth_kept_index(flags: *i64, n: i64, k: i64) -> i64
called by 1: main