summaryrefslogtreecommitdiff
path: root/glib
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2018-06-19 11:13:50 +0000
committerPhilip Withnall <philip@tecnocode.co.uk>2018-06-19 11:13:50 +0000
commitdd51b05e19bd370a7a84fc6d2f851e3dbbfd0c8a (patch)
treef81d5ef21dd115c615f2afb2f6a64806cddef5f2 /glib
parentf784df722da9eaf4b9e899d1f0562085ef0918d7 (diff)
parentc1a8e93dc42122383483ef9d9ed748e9330dd2ec (diff)
downloadglib-dd51b05e19bd370a7a84fc6d2f851e3dbbfd0c8a.tar.gz
Merge branch 'non-atomicity-of-g_file_set_contents' into 'master'
gfileutils: document non-atomicity of g_file_set_contents() See merge request GNOME/glib!118
Diffstat (limited to 'glib')
-rw-r--r--glib/gfileutils.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/glib/gfileutils.c b/glib/gfileutils.c
index 380c8d147..1e7a771a9 100644
--- a/glib/gfileutils.c
+++ b/glib/gfileutils.c
@@ -1173,6 +1173,17 @@ write_to_temp_file (const gchar *contents,
* lists, metadata etc. may be lost. If @filename is a symbolic link,
* the link itself will be replaced, not the linked file.
*
+ * - On UNIX, if @filename already exists and is non-empty, and if the system
+ * supports it (via a journalling filesystem or equivalent), the fsync()
+ * call (or equivalent) will be used to ensure atomic replacement: @filename
+ * will contain either its old contents or @contents, even in the face of
+ * system power loss, the disk being unsafely removed, etc.
+ *
+ * - On UNIX, if @filename does not already exist or is empty, there is a
+ * possibility that system power loss etc. after calling this function will
+ * leave @filename empty or full of NUL bytes, depending on the underlying
+ * filesystem.
+ *
* - On Windows renaming a file will not remove an existing file with the
* new name, so on Windows there is a race condition between the existing
* file being removed and the temporary file being renamed.