aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2017-02-27 10:20:25 +0100
committerGitHub <noreply@github.com>2017-02-27 10:20:25 +0100
commit8c8ce1832e780f87b2922ba3acf0d44f78c50931 (patch)
treeb4188c6c617bce73f806019d205129cee1f64e55 /src/nvim/os
parente502cca010357773252c686ef535bb2998aeb50b (diff)
parent31cdb227ba60e8867b3cb8e60ae8215290dd85a4 (diff)
downloadrneovim-8c8ce1832e780f87b2922ba3acf0d44f78c50931.tar.gz
rneovim-8c8ce1832e780f87b2922ba3acf0d44f78c50931.tar.bz2
rneovim-8c8ce1832e780f87b2922ba3acf0d44f78c50931.zip
Merge #6111 from ZyX-I/split-eval'/os-fileio
Refactor writefile() and create more tests for it
Diffstat (limited to 'src/nvim/os')
-rw-r--r--src/nvim/os/fileio.c8
-rw-r--r--src/nvim/os/fileio.h2
2 files changed, 9 insertions, 1 deletions
diff --git a/src/nvim/os/fileio.c b/src/nvim/os/fileio.c
index cf5bfd60ae..775f2bd449 100644
--- a/src/nvim/os/fileio.c
+++ b/src/nvim/os/fileio.c
@@ -62,6 +62,8 @@ int file_open(FileDescriptor *const ret_fp, const char *const fname,
FLAG(flags, kFileCreate, O_CREAT|O_WRONLY, kTrue, !(flags & kFileCreateOnly));
FLAG(flags, kFileTruncate, O_TRUNC|O_WRONLY, kTrue,
!(flags & kFileCreateOnly));
+ FLAG(flags, kFileAppend, O_APPEND|O_WRONLY, kTrue,
+ !(flags & kFileCreateOnly));
FLAG(flags, kFileReadOnly, O_RDONLY, kFalse, wr != kTrue);
#ifdef O_NOFOLLOW
FLAG(flags, kFileNoSymlink, O_NOFOLLOW, kNone, true);
@@ -153,7 +155,11 @@ int file_fsync(FileDescriptor *const fp)
fp->_error = 0;
return error;
}
- return os_fsync(fp->fd);
+ const int error = os_fsync(fp->fd);
+ if (error != UV_EINVAL && error != UV_EROFS) {
+ return error;
+ }
+ return 0;
}
/// Buffer used for writing
diff --git a/src/nvim/os/fileio.h b/src/nvim/os/fileio.h
index 2cffd5c851..0b55cc695f 100644
--- a/src/nvim/os/fileio.h
+++ b/src/nvim/os/fileio.h
@@ -30,6 +30,8 @@ typedef enum {
kFileTruncate = 32, ///< Truncate the file if it exists.
///< Implies kFileWriteOnly. Cannot be used with
///< kFileCreateOnly.
+ kFileAppend = 64, ///< Append to the file. Implies kFileWriteOnly. Cannot
+ ///< be used with kFileCreateOnly.
} FileOpenFlags;
static inline bool file_eof(const FileDescriptor *const fp)