aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/os/fs.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-05-20 22:33:19 +0200
committerJustin M. Keyes <justinkz@gmail.com>2019-05-20 22:33:19 +0200
commit7cc01c704c86f45854c29cb8427ed3b3029b4188 (patch)
tree77210b9f4ae69a023e65d9e5e4a3caf8951a6c1d /src/nvim/os/fs.c
parentb9ba1295b466a440600b36a717c701bfcea53dbc (diff)
parent6feb9cb09d243eb811e301b39dbfbba5863617be (diff)
downloadrneovim-7cc01c704c86f45854c29cb8427ed3b3029b4188.tar.gz
rneovim-7cc01c704c86f45854c29cb8427ed3b3029b4188.tar.bz2
rneovim-7cc01c704c86f45854c29cb8427ed3b3029b4188.zip
Merge #9709 'fileio: use os_copy to create backups'
ref #8288
Diffstat (limited to 'src/nvim/os/fs.c')
-rw-r--r--src/nvim/os/fs.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c
index 8d9de1253e..8c7dfcdee7 100644
--- a/src/nvim/os/fs.c
+++ b/src/nvim/os/fs.c
@@ -643,6 +643,21 @@ ptrdiff_t os_write(const int fd, const char *const buf, const size_t size,
return (ptrdiff_t)written_bytes;
}
+/// Copies a file from `path` to `new_path`.
+///
+/// @see http://docs.libuv.org/en/v1.x/fs.html#c.uv_fs_copyfile
+///
+/// @param path Path of file to be copied
+/// @param path_new Path of new file
+/// @param flags Bitwise OR of flags defined in <uv.h>
+/// @return 0 on success, or libuv error code on failure.
+int os_copy(const char *path, const char *new_path, int flags)
+{
+ int r;
+ RUN_UV_FS_FUNC(r, uv_fs_copyfile, path, new_path, flags, NULL);
+ return r;
+}
+
/// Flushes file modifications to disk.
///
/// @param fd the file descriptor of the file to flush to disk.