file

Byte-file and text-file helpers for contiguous byte storage and UTF-8 string values.


File model


getErrnoText (errnum -- textView)

Returns one StringView for the supplied error number.


loadFile (name -- result)

Loads one whole file into a byte-array result record.


saveFile (name data -- result)

Saves contiguous byte storage to one file.


loadString (name -- result)

Loads one whole file into a string result record.


saveString (name text -- success)

Saves text bytes to one file and reports whether the whole operation succeeded.


appendString (name text -- success)

Appends text bytes to the end of one file and reports whether the whole operation succeeded.


Examples

Compile-time example: signature-level result schemas

"file" use
"control" use

{} () {} [
  "sample.txt" "alpha" saveString printStack _:;
  "sample.txt" loadString.success printStack _:;
  "sample.txt" loadString.data.size printStack _:;
  "sample.txt" "beta" appendString printStack _:;
] "main" exportFunction

Expected Output During Compilation

Cond
Cond Cref
Int32
Cond

Runtime example

"file" use
"String" use
"control" use

{} Int32 {} [
  "sample.txt" "alpha" saveString drop
  "sample.txt" "beta" appendString drop
  loaded: "sample.txt" loadString;
  loaded.data print
  0
] "main" exportFunction

Expected Output

alphabeta

See also