From 5b609d292642a9146a64f60ff75e3bdc44c8d14a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 25 Apr 2018 19:22:18 +0200 Subject: text: use mkstemp(3) for temporary file creation in atomic saves Instead of simply appending a tilde to the original file name, we now create an unique temporary file based on the pattern `.filename.vis.XXXXXX`. In case the file does not yet exist, we use 0666 & ~umask as permission, (this should match the previous `open(2)` based behavior). --- text.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'text.h') diff --git a/text.h b/text.h index 06b7843..2fa6aea 100644 --- a/text.h +++ b/text.h @@ -280,9 +280,10 @@ enum TextSaveMethod { /** * Save file atomically using `rename(2)`. * - * Creates a new file named `filename~` and tries to restore all important - * meta data. After which it is atomically moved to its final - * (possibly already existing) destination using `rename(2)`. + * Creates a temporary file, restores all important meta data, + * before moving it atomically to its final (possibly already + * existing) destination using `rename(2)`. For new files, + * permissions are set to `0666 & ~umask`. * * @rst * .. warning:: This approach does not work if: -- cgit v1.2.3