File.write
You're seeing just the function
write
, go back to File module for more information.
Specs
Writes content
to the file path
.
The file is created if it does not exist. If it exists, the previous
contents are overwritten. Returns :ok
if successful, or {:error, reason}
if an error occurs.
content
must be iodata
(a list of bytes or a binary). Setting the
encoding for this function has no effect.
Warning: Every time this function is invoked, a file descriptor is opened
and a new process is spawned to write to the file. For this reason, if you are
doing multiple writes in a loop, opening the file via File.open/2
and using
the functions in IO
to write to the file will yield much better performance
than calling this function multiple times.
Typical error reasons are:
:enoent
- a component of the file name does not exist:enotdir
- a component of the file name is not a directory; on some platforms,:enoent
is returned instead:enospc
- there is no space left on the device:eacces
- missing permission for writing the file or searching one of the parent directories:eisdir
- the named file is a directory
Check File.open/2
for other available options.