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). --- sam.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'sam.c') diff --git a/sam.c b/sam.c index 304f572..6909020 100644 --- a/sam.c +++ b/sam.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "sam.h" #include "vis-core.h" #include "buffer.h" @@ -1670,7 +1671,7 @@ static bool cmd_write(Vis *vis, Win *win, Command *cmd, const char *argv[], Sele if (write_entire_file) *r = text_range_new(0, text_size(text)); - TextSave *ctx = text_save_begin(text, path, file->save_method); + TextSave *ctx = text_save_begin(text, AT_FDCWD, path, file->save_method); if (!ctx) { const char *msg = errno ? strerror(errno) : "try changing `:set savemethod`"; vis_info_show(vis, "Can't write `%s': %s", path, msg); -- cgit v1.2.3