diff options
author | Thomas Wienecke <wienecke.t@gmail.com> | 2014-03-04 20:50:48 +0100 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2014-03-05 15:01:19 -0300 |
commit | 8bb672e6a088eb77d98d182bd46551986b52eb49 (patch) | |
tree | 8ac1a7d0ffd2839da23a1a4a01e5a8a7d301d7a3 /src | |
parent | 1e5a6acebd9f4c5fec9f31a9b7863fc90167a648 (diff) | |
download | rneovim-8bb672e6a088eb77d98d182bd46551986b52eb49.tar.gz rneovim-8bb672e6a088eb77d98d182bd46551986b52eb49.tar.bz2 rneovim-8bb672e6a088eb77d98d182bd46551986b52eb49.zip |
Port mch_isdir to libuv.
Diffstat (limited to 'src')
-rw-r--r-- | src/ex_cmds.c | 1 | ||||
-rw-r--r-- | src/ex_cmds2.c | 1 | ||||
-rw-r--r-- | src/main.c | 1 | ||||
-rw-r--r-- | src/os/fs.c | 19 | ||||
-rw-r--r-- | src/os/os.h | 1 | ||||
-rw-r--r-- | src/os_unix.c | 20 | ||||
-rw-r--r-- | src/os_unix.h | 1 | ||||
-rw-r--r-- | src/spell.c | 1 | ||||
-rw-r--r-- | src/undo.c | 1 |
9 files changed, 25 insertions, 21 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 730df906a1..68b5727786 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -52,6 +52,7 @@ #include "ui.h" #include "undo.h" #include "window.h" +#include "os/os.h" static int linelen(int *has_tab); static void do_filter(linenr_T line1, linenr_T line2, exarg_T *eap, diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index b23f6ad46a..f08aab0300 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -39,6 +39,7 @@ #include "term.h" #include "undo.h" #include "window.h" +#include "os/os.h" static void cmd_source(char_u *fname, exarg_T *eap); diff --git a/src/main.c b/src/main.c index f2e83234a5..e3f14707ca 100644 --- a/src/main.c +++ b/src/main.c @@ -42,6 +42,7 @@ #include "ui.h" #include "version.h" #include "window.h" +#include "os/os.h" /* Maximum number of commands from + or -c arguments. */ #define MAX_ARG_CMDS 10 diff --git a/src/os/fs.c b/src/os/fs.c index 0b83ca319e..bf9de63355 100644 --- a/src/os/fs.c +++ b/src/os/fs.c @@ -160,3 +160,22 @@ int mch_is_full_name(char_u *fname) return *fname == '/' || *fname == '~'; } +/* + * return TRUE if "name" is a directory + * return FALSE if "name" is not a directory + * return FALSE for error + */ +int mch_isdir(char_u *name) +{ + uv_fs_t request; + if (0 != uv_fs_stat(uv_default_loop(), &request, (const char*) name, NULL)) { + return FALSE; + } + + if (!S_ISDIR(request.statbuf.st_mode)) { + return FALSE; + } + + return TRUE; +} + diff --git a/src/os/os.h b/src/os/os.h index 1ef311b32c..8d3caa849f 100644 --- a/src/os/os.h +++ b/src/os/os.h @@ -8,5 +8,6 @@ int mch_chdir(char *path); int mch_dirname(char_u *buf, int len); int mch_full_name (char_u *fname, char_u *buf, int len, int force); int mch_is_full_name (char_u *fname); +int mch_isdir(char_u *name); #endif diff --git a/src/os_unix.c b/src/os_unix.c index fdbaba466a..4ba7b79611 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -1319,26 +1319,6 @@ void mch_hide(char_u *name) /* can't hide a file */ } -/* - * return TRUE if "name" is a directory - * return FALSE if "name" is not a directory - * return FALSE for error - */ -int mch_isdir(char_u *name) -{ - struct stat statb; - - if (*name == NUL) /* Some stat()s don't flag "" as an error. */ - return FALSE; - if (stat((char *)name, &statb)) - return FALSE; -#ifdef _POSIX_SOURCE - return S_ISDIR(statb.st_mode) ? TRUE : FALSE; -#else - return (statb.st_mode & S_IFMT) == S_IFDIR ? TRUE : FALSE; -#endif -} - int executable_file(char_u *name); /* diff --git a/src/os_unix.h b/src/os_unix.h index 02591f725f..92222bbca6 100644 --- a/src/os_unix.h +++ b/src/os_unix.h @@ -37,7 +37,6 @@ vim_acl_T mch_get_acl(char_u *fname); void mch_set_acl(char_u *fname, vim_acl_T aclent); void mch_free_acl(vim_acl_T aclent); void mch_hide(char_u *name); -int mch_isdir(char_u *name); int mch_can_exe(char_u *name); int mch_nodetype(char_u *name); void mch_early_init(void); diff --git a/src/spell.c b/src/spell.c index df264ee3fa..d403e17b3f 100644 --- a/src/spell.c +++ b/src/spell.c @@ -325,6 +325,7 @@ #include "term.h" #include "ui.h" #include "undo.h" +#include "os/os.h" #ifndef UNIX /* it's in os_unix_defs.h for Unix */ # include <time.h> /* for time_t */ diff --git a/src/undo.c b/src/undo.c index 0903dbf708..87adf3f9bc 100644 --- a/src/undo.c +++ b/src/undo.c @@ -98,6 +98,7 @@ #include "quickfix.h" #include "screen.h" #include "sha256.h" +#include "os/os.h" static long get_undolevel(void); static void u_unch_branch(u_header_T *uhp); |