main.tri (913B)
1 !import foundation as B 2 !import fileio as IO 3 !import inspection as Inspect 4 !export main 5 -- foundation, fileio and inspection are offline package bindings. 6 -- Run with --io --no-result; native file access uses OS process authority. 7 -- Read once within an explicit byte budget: hash and report use that same value. 8 main path = IO.io (IO.bind (IO.readBytes path 1048576) (reply : B.matchResult 9 (problem _ : IO.abortIO ["Read failed" problem]) 10 (bytes _ : B.matchResult 11 (code _ : IO.abortIO ["Invalid Arboricx bundle" (Inspect.describeError code) code]) 12 (summary _ : IO.bind (IO.sha256Hex bytes 1048576) (digestReply : B.matchResult 13 (problem _ : IO.abortIO ["Hash failed" problem]) 14 (digest _ : IO.putStr (B.append "arboricx.inspect.v1\nbundle-sha256\t" 15 (B.append digest (B.append "\n" (Inspect.renderSummary summary))))) 16 digestReply)) 17 (Inspect.inspectBundle bytes)) 18 reply))