tur/io

stdlib/io.tur
defn

file-size

(file-size [f])

return the byte size of an already-open file.

fa FILE* cast to int64_t (as returned by fopen).
The file size in bytes as an int.

  (file-size my-file-ptr)  ; => 1024
defn

Real-FileSystem

(Real-FileSystem)

create a FileSystem capability backed by libc.

Since: Phase 16

defn

Real-FileSystem-free

(Real-FileSystem-free [fs])

release a FileSystem capability created by Real-FileSystem.

fsthe FileSystem pointer returned by Real-FileSystem.

Since: Phase 16

defn

read-file

(read-file [path])

read an entire file into a newly allocated buffer.

paththe filesystem path to open (:cstr).

Since: Phase 16

defn

write-file

(write-file [path data len])

write a byte buffer to a file, overwriting any existing content.

paththe destination filesystem path (:cstr).
datapointer to the data to write.
lennumber of bytes to write.

Since: Phase 16

defn

file-exists?

(file-exists? [path])

test whether a file is accessible for reading.

paththe filesystem path to check (:cstr).

Since: Phase 16

defn

list-dir

(list-dir [path])

list all non-hidden entries in a directory.

paththe directory path to list (:cstr).

Since: Phase 16

defn

free-dir-listing

(free-dir-listing [entries])

free a directory listing returned by list-dir.

entriesthe NULL-terminated string array returned by list-dir.

Since: Phase 16