GLib.file_set_contents
Description: Reference for GLib.file_set_contents

### Function

# GLibfile_set_contents

since: 2.8

#### Declaration

    gboolean
    g_file_set_contents (
      const gchar* filename,
      const gchar* contents,
      gssize length,
      GError** error
    )

#### Description

Writes all of `contents` to a file named `filename`. This is a convenience wrapper around calling `g_file_set_contents_full()` with `flags` set to `G_FILE_SET_CONTENTS_CONSISTENT | G_FILE_SET_CONTENTS_ONLY_EXISTING` and `mode` set to `0666`.

Available since: 2.8

#### Parameters

`filename`

  Type: `const gchar*`

  Name of a file to write `contents` to, in the GLib file name encoding.

  The data is owned by the caller of the function.
  The value is a file system path, using the OS encoding.

`contents`

  Type: An array of `guint8`

  String to write to the file.

  The length of the array is specified in the `length` argument.
  The data is owned by the caller of the function.

`length`

  Type: `gssize`

  Length of `contents`, or -1 if `contents` is a nul-terminated string.

`error`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will be left initialized to `NULL` by the function if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `gboolean`

`TRUE` on success, `FALSE` if an error occurred.