file_stream(path, @key options, buffer_mode, transcoder, permissions = 0o666)
Return a new input/output stream for the file at
options must be a list of symbols that control aspects of file operations.
The options that are valid are
'create option requires that the file does not exist (otherwise an exception is raised) and
creates the file when it is opened.
'no_create option requires that the file exist (otherwise an exception is raised).
'maybe_create option will create the file if it does not exist. This is the default option.
'append option controls whether output will be added to the end of the file.
This is useful for writing to log files that might be open by more than one process.
By default appending is turned-off.
'truncate option controls whether the file will be truncated when it is opened.
This option is turned-on by default when no
'append option is provided and turned-off
'append is not provided.
Buffer_mode is a symbol that controls buffering. Valid values are
By default, buffering is turned off.
transcoder is present and is not
false, it must be a
transcoder object and
file_writer will return a textual output stream that will be encoded with
Otherwise, a binary output stream is returned.
Permissions control the UNIX permissions that will be attached to the file if it is created.
The default value of this setting is
let s = file_stream("out.txt", options = ['create]) showln(stream = s, "hello, world") set_stream_position(s, 0) read_line(s) // hello, world
Core Module Index | Contents