summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2021-03-11 20:48:44 +1100
committerMaxime Coste <mawww@kakoune.org>2021-03-11 20:48:44 +1100
commit8e463e63ea2e837a442c55580b1bb0d72ec5b25f (patch)
tree901e5a7f09964ea90ab7108cd30f3bcba5028b8a /src
parent7f8f748d061dba19b3465ebce98885d6d3df9883 (diff)
Do not use replace write method when writing to a non-regular file
Fixes #4098
Diffstat (limited to 'src')
-rw-r--r--src/file.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/file.cc b/src/file.cc
index 3424afef..8c9705b5 100644
--- a/src/file.cc
+++ b/src/file.cc
@@ -361,7 +361,8 @@ void write_buffer_to_file(Buffer& buffer, StringView filename,
bool replace = method == WriteMethod::Replace;
bool force = flags & WriteFlags::Force;
- if ((replace or force) and ::stat(zfilename, &st) != 0)
+ if ((replace or force) and (::stat(zfilename, &st) != 0 or
+ (sb.st_mode & S_IFMT) != S_IFREG))
{
force = false;
replace = false;