mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 05:05:00 -07:00
Port mch_isdir to libuv.
This commit is contained in:
parent
1e5a6acebd
commit
8bb672e6a0
@ -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,
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
19
src/os/fs.c
19
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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
/*
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
@ -19,7 +19,7 @@ describe 'os_unix function', ->
|
||||
lfs.touch 'unit-test-directory/test.file'
|
||||
|
||||
-- Since the tests are executed, they are called by an executable. We use
|
||||
-- that to unit test several functions.
|
||||
-- that executable for several asserts.
|
||||
export absolute_executable = arg[0]
|
||||
|
||||
-- Split absolute_executable into a directory and the actual file name and
|
||||
|
Loading…
Reference in New Issue
Block a user