From 091b6e216c74678e244edb8c3499d86f43d02df4 Mon Sep 17 00:00:00 2001 From: Rui Abreu Ferreira Date: Tue, 27 Oct 2015 10:44:15 +0000 Subject: Return libuv return code from os_stat() Instead of returning bool from os_stat return the actual libuv return code. This function is static and used internally in nvim/os/fs.c it should not impact the rest of the API. This is a first step to change other fs functions. --- src/nvim/os/fs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 94b0be90fd..e13691652a 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -204,15 +204,15 @@ int os_open(const char* path, int flags, int mode) /// Get stat information for a file. /// -/// @return OK on success, FAIL if a failure occurred. -static bool os_stat(const char *name, uv_stat_t *statbuf) +/// @return libuv return code. +static int os_stat(const char *name, uv_stat_t *statbuf) FUNC_ATTR_NONNULL_ALL { uv_fs_t request; int result = uv_fs_stat(&fs_loop, &request, name, NULL); *statbuf = request.statbuf; uv_fs_req_cleanup(&request); - return (result == kLibuvSuccess); + return result; } /// Get the file permissions for a given file. @@ -222,7 +222,7 @@ int32_t os_getperm(const char_u *name) FUNC_ATTR_NONNULL_ALL { uv_stat_t statbuf; - if (os_stat((char *)name, &statbuf)) { + if (os_stat((char *)name, &statbuf) == kLibuvSuccess) { return (int32_t)statbuf.st_mode; } else { return -1; @@ -270,7 +270,7 @@ bool os_file_exists(const char_u *name) FUNC_ATTR_NONNULL_ALL { uv_stat_t statbuf; - return os_stat((char *)name, &statbuf); + return os_stat((char *)name, &statbuf) == kLibuvSuccess; } /// Check if a file is readable. @@ -470,7 +470,7 @@ int os_remove(const char *path) bool os_fileinfo(const char *path, FileInfo *file_info) FUNC_ATTR_NONNULL_ALL { - return os_stat(path, &(file_info->stat)); + return os_stat(path, &(file_info->stat)) == kLibuvSuccess; } /// Get the file information for a given path without following links @@ -572,7 +572,7 @@ bool os_fileid(const char *path, FileID *file_id) FUNC_ATTR_NONNULL_ALL { uv_stat_t statbuf; - if (os_stat(path, &statbuf)) { + if (os_stat(path, &statbuf) == kLibuvSuccess) { file_id->inode = statbuf.st_ino; file_id->device_id = statbuf.st_dev; return true; -- cgit