diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2014-07-14 09:06:36 -0400 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2014-07-14 09:06:36 -0400 |
commit | f693b4043d29ec21d990661450cdbd353da0e036 (patch) | |
tree | 4e06241295ab8e32358a06eff245431daae52d24 /src/nvim/os/fs.c | |
parent | bf6b0e3c0aa34beca13eee898decdf0fcde8b502 (diff) | |
parent | 0ceebc2c913cc497735e001772cb6b395c36cecc (diff) | |
download | rneovim-f693b4043d29ec21d990661450cdbd353da0e036.tar.gz rneovim-f693b4043d29ec21d990661450cdbd353da0e036.tar.bz2 rneovim-f693b4043d29ec21d990661450cdbd353da0e036.zip |
Merge #846 'impl mch_open with libuv'
Diffstat (limited to 'src/nvim/os/fs.c')
-rw-r--r-- | src/nvim/os/fs.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index c1cb418d5c..dce95eb3c9 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -150,6 +150,24 @@ static bool is_executable_in_path(const char_u *name) return false; } +/// Opens or creates a file and returns a non-negative integer representing +/// the lowest-numbered unused file descriptor, for use in subsequent system +/// calls (read, write, lseek, fcntl, etc.). If the operation fails, `-errno` +/// is returned, and no file is created or modified. +/// +/// @param flags Bitwise OR of flags defined in <fcntl.h> +/// @param mode Permissions for the newly-created file (IGNORED if 'flags' is +/// not `O_CREAT` or `O_TMPFILE`), subject to the current umask +/// @return file descriptor, or negative `errno` on failure +int os_open(const char* path, int flags, int mode) +{ + uv_fs_t open_req; + int r = uv_fs_open(uv_default_loop(), &open_req, path, flags, mode, NULL); + uv_fs_req_cleanup(&open_req); + // r is the same as open_req.result (except for OOM: then only r is set). + return r; +} + /// Get stat information for a file. /// /// @return OK on success, FAIL if a failure occurred. @@ -291,7 +309,7 @@ int os_remove(const char *path) /// Get the file information for a given path /// -/// @param file_descriptor File descriptor of the file. +/// @param path Path to the file. /// @param[out] file_info Pointer to a FileInfo to put the information in. /// @return `true` on success, `false` for failure. bool os_get_file_info(const char *path, FileInfo *file_info) |