aboutsummaryrefslogtreecommitdiff
path: root/sam.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2020-08-21 12:34:36 +0200
committerMarc André Tanner <mat@brain-dump.org>2020-08-29 13:34:41 +0200
commit397a8a0688c0be874f0e1826ed51d88db039d769 (patch)
tree0378c4d1f976e37be02da5a61690b3178be49509 /sam.c
parent57a13bcea2b70c09aff2953bd0a2d451659e9bdd (diff)
downloadvis-397a8a0688c0be874f0e1826ed51d88db039d769.tar.gz
vis-397a8a0688c0be874f0e1826ed51d88db039d769.tar.xz
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).
Diffstat (limited to 'sam.c')
-rw-r--r--sam.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sam.c b/sam.c
index 304f572..6909020 100644
--- a/sam.c
+++ b/sam.c
@@ -23,6 +23,7 @@
#include <errno.h>
#include <unistd.h>
#include <limits.h>
+#include <fcntl.h>
#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);