~/bend-docscommunity

src/file.bend checks

raw source on the hub · import snap@1.1.0.0/src/file.bend as MFile

src/file: a file's text, read whole, or None when it cannot be opened.

1 import
import Base

Definitions

def file.slurp.end source · line 5 · raw

@file:File -> @acc:String -> IO(String)

the handle closed, and whatever was gathered

def file.slurp.cut source · line 11 · raw

@chunk:String -> @file:File -> @acc:String -> @rest:(@_:File -> @_:String -> IO(String)) -> IO(String)

an empty chunk means the end of the file

def file.slurp.more source · line 19 · raw

@res:Result<&1, &1, Pair(U32, String), String> -> @file:File -> @acc:String -> @rest:(@_:File -> @_:String -> IO(String)) -> IO(String)

a failed read ends the file as surely as an empty one

def file.slurp.next source · line 32 · raw

@got:Pair(File, Result<&1, &1, Pair(U32, String), String>) -> @acc:String -> @rest:(@_:File -> @_:String -> IO(String)) -> IO(String)

the handle comes back paired with what it read

def file.slurp source · line 41 · raw

@fuel:Nat -> @file:File -> @acc:String -> IO(String)

the whole file, read in chunks until one is empty, or the fuel is

def file.read.opened source · line 51 · raw

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

what an opened file holds, or nothing when it would not open

def file.read source · line 61 · raw

@path:String -> IO(Maybe<&2, String>)

a file's text, or None when it cannot be opened

def file.text_of source · line 67 · raw

@got:Maybe<&2, String> -> String

a file's text, or "" when there is none