diff options
author | Stefan Hoffmann <stefan991@gmail.com> | 2014-05-27 23:07:15 +0200 |
---|---|---|
committer | Stefan Hoffmann <stefan991@gmail.com> | 2014-06-27 13:59:29 +0200 |
commit | a0394f5e77cdc04529a444b186d7d7aefc23ad82 (patch) | |
tree | 36d605732b87bac5a6855db6550e5cb669b23514 | |
parent | de359489600f95a83f8891a3b2fbc86f98278407 (diff) | |
download | rneovim-a0394f5e77cdc04529a444b186d7d7aefc23ad82.tar.gz rneovim-a0394f5e77cdc04529a444b186d7d7aefc23ad82.tar.bz2 rneovim-a0394f5e77cdc04529a444b186d7d7aefc23ad82.zip |
FileID: make `os_stat()` static
-rw-r--r-- | src/nvim/os/fs.c | 43 |
1 files changed, 12 insertions, 31 deletions
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index e0e2fbf3c3..65b88c06f4 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -149,19 +149,13 @@ static bool is_executable_in_path(const char_u *name) /// Get stat information for a file. /// /// @return OK on success, FAIL if a failure occurred. -int os_stat(const char_u *name, uv_stat_t *statbuf) +static bool os_stat(const char *name, uv_stat_t *statbuf) { uv_fs_t request; - int result = uv_fs_stat(uv_default_loop(), &request, - (const char *)name, NULL); + int result = uv_fs_stat(uv_default_loop(), &request, name, NULL); *statbuf = request.statbuf; uv_fs_req_cleanup(&request); - - if (result == kLibuvSuccess) { - return OK; - } - - return FAIL; + return (result == kLibuvSuccess); } /// Get the file permissions for a given file. @@ -170,10 +164,10 @@ int os_stat(const char_u *name, uv_stat_t *statbuf) int32_t os_getperm(const char_u *name) { uv_stat_t statbuf; - if (os_stat(name, &statbuf) == FAIL) { - return -1; - } else { + if (os_stat((char *)name, &statbuf)) { return (int32_t)statbuf.st_mode; + } else { + return -1; } } @@ -200,11 +194,7 @@ int os_setperm(const char_u *name, int perm) bool os_file_exists(const char_u *name) { uv_stat_t statbuf; - if (os_stat(name, &statbuf) == OK) { - return true; - } - - return false; + return os_stat((char *)name, &statbuf); } /// Check if a file is readonly. @@ -238,7 +228,7 @@ int os_file_is_writable(const char *name) bool os_get_file_size(const char *name, off_t *size) { uv_stat_t statbuf; - if (os_stat((char_u *)name, &statbuf) == OK) { + if (os_stat(name, &statbuf)) { *size = statbuf.st_size; return true; } @@ -302,10 +292,7 @@ int os_remove(const char *path) /// @return `true` on success, `false` for failure. bool os_get_file_info(const char *path, FileInfo *file_info) { - if (os_stat((char_u *)path, &(file_info->stat)) == OK) { - return true; - } - return false; + return os_stat(path, &(file_info->stat)); } /// Get the file information for a given path without following links @@ -319,10 +306,7 @@ bool os_get_file_info_link(const char *path, FileInfo *file_info) int result = uv_fs_lstat(uv_default_loop(), &request, path, NULL); file_info->stat = request.statbuf; uv_fs_req_cleanup(&request); - if (result == kLibuvSuccess) { - return true; - } - return false; + return (result == kLibuvSuccess); } /// Get the file information for a given file descriptor @@ -336,10 +320,7 @@ bool os_get_file_info_fd(int file_descriptor, FileInfo *file_info) int result = uv_fs_fstat(uv_default_loop(), &request, file_descriptor, NULL); file_info->stat = request.statbuf; uv_fs_req_cleanup(&request); - if (result == kLibuvSuccess) { - return true; - } - return false; + return (result == kLibuvSuccess); } /// Compare the inodes of two FileInfos @@ -380,7 +361,7 @@ uint64_t os_file_info_get_inode(const FileInfo *file_info) bool os_get_file_id(const char *path, FileID *file_id) { uv_stat_t statbuf; - if (os_stat((char_u *)path, &statbuf) == OK) { + if (os_stat(path, &statbuf)) { file_id->inode = statbuf.st_ino; file_id->device_id = statbuf.st_dev; return true; |