buffer_to_file

From Kolmafia
Jump to navigation Jump to search

Function Syntax

boolean buffer_to_filebuffer data, string filepath )

Saves a buffer to a text file. Returns true on success, false on failure.
  • data: Buffer to save
  • filepath: Path to the text file to save

This function was added in r19439.

Code Samples

Saves a string (automatically converted to a buffer) to a text file.

string contents = "Hello, world!";
if (!buffer_to_file(contents, "mydata.txt")) {
   abort("Failed to save data to mydata.txt");
}

See Also

file_to_array() | file_to_buffer() | file_to_map() | map_to_file()