No matching definitions.

tur/fs-string

stdlib/fs-string.tur

read a whole file into an owned String.

fs/read-string, the String counterpart of fs/read-text, in a module of its own: (load "stdlib/fs-string.tur"). It loads stdlib/fs.tur and stdlib/string.tur. It is not in fs.tur because string.tur brings the Show typeclass with it, and a program that loads fs.tur and defines its own show would then fail to compile with an ambiguous-dispatch error.

Compiled only, like the rest of fs.tur: under --interpret it stops with "inline-C not supported in interpreter mode" (docs/reported/fs-functions-compiled-only.md).

Since: markdown-library-plan S3

defn

fs/read-string

(fs/read-string [path :cstr])

read an entire file into a fresh owned String.

fs/read-text for code that works in String: the whole file, as an owned String the caller releases with string/release. Every byte is kept, NUL included, since the String carries its own length; reading through fs/read-text and string/adopt-cstr would stop at the first NUL. A pipe, a FIFO or /dev/stdin is read to its end, as fs/read-text does.

pathNUL-terminated path cstr

(Ok s) holding the file's bytes, or (Err e) carrying the errno.

(match (fs/read-string "README.md")
  (Ok s)  (do (println (string/len s)) (string/release s))
  (Err e) (println (io-error/message e)))

Since: markdown-library-plan S3