From 397a8a0688c0be874f0e1826ed51d88db039d769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Fri, 21 Aug 2020 12:34:36 +0200 Subject: text: provide save function taking a directory descriptor The standard does not specify mkstempat(3). We currently implement it in a non thread safe manner, by temporarily changing the process working directory before invoking mkstemp(3). --- text.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'text.h') diff --git a/text.h b/text.h index 43ff9c1..6fd484b 100644 --- a/text.h +++ b/text.h @@ -347,10 +347,12 @@ enum TextSaveMethod { * @endrst */ bool text_save(Text*, const char *filename); +bool text_saveat(Text*, int dirfd, const char *filename); /** * Save the whole text to the given file name, using the specified method. */ bool text_save_method(Text*, const char *filename, enum TextSaveMethod); +bool text_saveat_method(Text*, int dirfd, const char *filename, enum TextSaveMethod); /** * Setup a sequence of write operations. @@ -363,7 +365,7 @@ bool text_save_method(Text*, const char *filename, enum TextSaveMethod); * ``text_save_cancel`` to release the underlying resources. * @endrst */ -TextSave *text_save_begin(Text*, const char *filename, enum TextSaveMethod); +TextSave *text_save_begin(Text*, int dirfd, const char *filename, enum TextSaveMethod); /** * Write file range. * @return The number of bytes written or ``-1`` in case of an error. -- cgit v1.2.3