name of a file to write contents to, in the GLib file name encoding
string to write to the file
flags controlling the safety vs speed of the operation
file mode, as passed to open(); typically this will be 0666
true on success, false if an error occurred
Writes all of contents to a file named filename, with good error checking. If a file called filename already exists it will be overwritten.
flags control the properties of the write operation: whether it’s atomic, and what the tradeoff is between returning quickly or being resilient to system crashes.
As this function performs file I/O, it is recommended to not call it anywhere where blocking would cause problems, such as in the main loop of a graphical application. In particular, if flags has any value other than G_FILE_SET_CONTENTS_NONE then this function may call fsync().
If G_FILE_SET_CONTENTS_CONSISTENT is set in flags, the operation is atomic in the sense that it is first written to a temporary file which is then renamed to the final name.
Notes:
If the call was successful, it returns true. If the call was not successful, it returns false and sets error. The error domain is G_FILE_ERROR. Possible error codes are those in the #GFileError enumeration.
Note that the name for the temporary file is constructed by appending up to 7 characters to filename.
If the file didn’t exist before and is created, it will be given the permissions from mode. Otherwise, the permissions of the existing file may be changed to mode depending on flags, or they may remain unchanged.