aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/fileio.c
diff options
context:
space:
mode:
authorSaid Al Attrach <alattrach.said@yahoo.com>2019-03-10 18:08:45 +0100
committerSaid Al Attrach <alattrach.said@yahoo.com>2019-03-10 18:11:30 +0100
commit8410c72b18b0c2d8cfbf98e57e2ab8869dd6af01 (patch)
tree5919dc242c74fc9d3084e841d1b12c0077d6ca6e /src/nvim/fileio.c
parentef5037e7f6e199ade4475d819842e66eb3bd8381 (diff)
downloadrneovim-8410c72b18b0c2d8cfbf98e57e2ab8869dd6af01.tar.gz
rneovim-8410c72b18b0c2d8cfbf98e57e2ab8869dd6af01.tar.bz2
rneovim-8410c72b18b0c2d8cfbf98e57e2ab8869dd6af01.zip
fs: add os_copy function that uses uv_fs_copyfile
Diffstat (limited to 'src/nvim/fileio.c')
-rw-r--r--src/nvim/fileio.c24
1 files changed, 3 insertions, 21 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index f111376d84..2828e7bddc 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -3517,28 +3517,10 @@ restore_backup:
MSG(_(e_interr));
ui_flush();
}
- if ((fd = os_open((char *)backup, O_RDONLY, 0)) >= 0) {
- if ((write_info.bw_fd = os_open((char *)fname,
- O_WRONLY | O_CREAT | O_TRUNC,
- perm & 0777)) >= 0) {
- // copy the file.
- write_info.bw_buf = smallbuf;
-#ifdef HAS_BW_FLAGS
- write_info.bw_flags = FIO_NOCONVERT;
-#endif
- while ((write_info.bw_len = read_eintr(fd, smallbuf,
- SMBUFSIZE)) > 0) {
- if (buf_write_bytes(&write_info) == FAIL) {
- break;
- }
- }
- if (close(write_info.bw_fd) >= 0
- && write_info.bw_len == 0) {
- end = 1; // success
- }
- }
- close(fd); // ignore errors for closing read file
+ // copy the file.
+ if (os_copy((char *)backup, (char *)fname, 0) == 0) {
+ end = 1;
}
} else {
if (vim_rename(backup, fname) == 0) {