(doc Raw "wrappers for functions from the C standard library. Consider using a more carpesque function from IO when it exists. For detailed documentation please consult the documentation of your system (e.g. under Linux try man fprint).")
(defmodule Raw
(doc stdin "the standard input file (thin wrapper for the C standard library).")
(register stdin (Ptr FILE) "stdin")
(doc stdout "the standard output file (thin wrapper for the C standard library).")
(register stdout (Ptr FILE) "stdout")
(doc stderr "the standard error file (thin wrapper for the C standard library).")
(register stderr (Ptr FILE) "stderr")
(doc get-char "gets a character from stdin (thin wrapper for getchar() from C standard library).")
(register get-char (Fn [] Int) "getchar")
(doc fgetc "gets a character from file (thin wrapper for the from C standard library).")
(register fgetc (Fn [(Ptr FILE)] Int) "fgetc")
(doc EOF "the End-Of-File character as a literal (thin wrapper for the C standard library)")
(doc fclose "closes a file pointer (thin wrapper for the C standard library).")
(register fclose (Fn [(Ptr FILE)] Int) "fclose")
(doc fclose! "same as (fclose) but to be used as a side effect.")
(defn fclose! [file]
(ignore (fclose file)) )
(private fwrite-)
(hidden fwrite-)
(register fwrite- (Fn [(Ptr CChar) Int Int (Ptr FILE)] Int) "fwrite")
(doc fwrite "writes a C-string to a file and returns the number of written items (thin wrapper for the C standard library). Consider using [`write-file`](#write-file) instead.")
(doc fwrite! "like fwrite but returns no indicator whether writing to file succeeded. Consider using fwrite instead.")
(defn fwrite! [data item-size items-count file]
(ignore (fwrite data item-size items-count file)) )
(private fread-)
(hidden fread-)
(register fread- (Fn [a Int Int (Ptr FILE)] Int) "fread")
(doc fread "reads from a file into C-String (thin wrapper for fread(cstr, item-size, items-count, file) from C standard library). Consider using [`read-file`](#read-file) or [`unsafe-read-file`](#unsafe-read-file) instead.")
(doc fflush "flushes a file pointer, i.e. commits every write (thin wrapper for the C standard library).")
(register fflush (Fn [(Ptr FILE)] Int) "fflush")
(doc fflush! "same as (fflush) but to be used as a side effect.")
(defn fflush! [file]
(ignore (fflush file)) )
(doc rewind "rewinds a file pointer, i.e. puts input and output stream to beginning (thin wrapper for the C standard library). If you want to verify, that this succeeded, use (fseek stream 0, SEEK_SET) instead. ")
(doc open-file "opens a file by name using a mode (e.g. [r]ead, [w]rite, [a]ppend), [rb] read binary...). See fopen() in the C standard library for a detailed description of valid parameters.")
(doc read->EOF "reads a file given by name until the End-Of-File character is reached. Please consider using read-file instead, even though this works fine for UTF-8 encoded input files.")
(doc unsafe-read-file "returns the contents of a file passed as argument as a string. Note: there is no way to distinguish the output for an empty file and a missing file!")
(register unsafe-read-file (Fn [&String] String))
(doc read-file "Reads the content of a file into a (Result String String).\nIt is intended for text files, since the way to determine the length of a String is to use strlen() which probably will be inaccurate for binaries.")