API Reference › Fs › Fs.write_text
method

Fs.write_text

Fs.write_text(p, s) -> bool

Writes a string to a file, replacing any existing contents. The write is atomic — the bytes go to a temporary file that is renamed into place — so an interrupted write never corrupts the previous file. Returns true on success.

Parameters

pthe path to write
sthe string contents

Example

program WriteText {
  entry {
    if Fs.write_text("settings.ini", "fullscreen=1") { print(1) }
  }
}
← All symbols