file_writer(path, @key options, buffer_mode, transcoder, permissions = 0o666)
Return a new output stream for the file identified by
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
// writing a utf-8 encoded text file: let t = transcoder('UTF_8) let f = file_writer("hello.txt", transcoder = t) write_chars("hello, world", f) close_writer(f)
Core Module Index | Contents