nx_find.nx
buildroot/runtime/nx_find.nx
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
imports: nx_syscalls.nxnx_string_ops.nxnx_dir.nx
imported by: nx_find_test.nx
structs
| none |
consts
| none |
functions
| 75 | func nx_find_filter_suffix( |
| 100 | func nx_find_filter_prefix( |
| 125 | func nx_find_filter_regular_files( |
| 146 | func nx_find_filter_skip_dotlike( |
| 170 | func nx_find_intersect( called by 1: main |
| 196 | func nx_find_count_kept(flags: *i64, n: i64) -> i64 called by 1: main |
| 208 | func nx_find_nth_kept_index(flags: *i64, n: i64, k: i64) -> i64 called by 1: main |