~/bend-docscommunity

src/dir.bend checks

raw source on the hub · import ezsys@0.1.0.0/src/dir.bend as Dir

ezsys/src/dir: every decision dir.list makes. It does no IO; src/sys.bend reads a directory's raw entry names with its own effect (SYS-TRUST-5) and hands them here. The answer drops exactly "." and ".." and sorts the rest ascending by String.order, which compares code points one by one: that is the bytewise order of their UTF-8 encodings.

1 import
import Base

Definitions

def dir.dot source · line 9 · raw

@+name:String -> Bool

whether a name is "." or ".."

def dir.insert.pick source · line 14 · raw

@first:Bool -> @+name:String -> @+next:String -> @+ys:List<&2, String> -> @rest:(@_:Unit -> List<&2, String>) -> List<&2, String>

name before next when it sorts first, else next and the rest with name put in them

def dir.insert source · line 28 · raw

@+name:String -> @xs:List<&2, String> -> List<&2, String>

a name put into a sorted list, before the first name it does not sort after

def dir.sort source · line 37 · raw

@xs:List<&2, String> -> List<&2, String>

a list sorted ascending by String.order (insertion sort)

def dir.keep.pick source · line 45 · raw

@dot:Bool -> @+name:String -> @rest:(@_:Unit -> List<&2, String>) -> List<&2, String>

a name kept unless it is "." or ".."

def dir.keep source · line 57 · raw

@xs:List<&2, String> -> List<&2, String>

the names that are not "." or "..", in their order

def dir.names source · line 65 · raw

@raw:List<&2, String> -> List<&2, String>

what dir.list answers for the raw names a directory read gave

def dir.step source · line 70 · raw

@res:Result<&1, &1, Pair(U32, String), List<&2, String>> -> Result<&1, &1, Pair(U32, String), List<&2, String>>

what dir.list answers for a directory read's answer: its names, or the failure unchanged